CN113992594B - Flow control method, flow control device, electronic equipment and computer readable storage medium - Google Patents

Flow control method, flow control device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113992594B
CN113992594B CN202111270940.9A CN202111270940A CN113992594B CN 113992594 B CN113992594 B CN 113992594B CN 202111270940 A CN202111270940 A CN 202111270940A CN 113992594 B CN113992594 B CN 113992594B
Authority
CN
China
Prior art keywords
token bucket
tokens
message
total length
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111270940.9A
Other languages
Chinese (zh)
Other versions
CN113992594A (en
Inventor
张赟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202111270940.9A priority Critical patent/CN113992594B/en
Publication of CN113992594A publication Critical patent/CN113992594A/en
Application granted granted Critical
Publication of CN113992594B publication Critical patent/CN113992594B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application provides a flow control method, a flow control device, an electronic device and a computer readable storage medium, wherein one specific embodiment of the method comprises the following steps: determining the total length of an initial message corresponding to the current period; determining current message data received in total at the current moment, and determining the total length of the current message corresponding to the current message data; determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message; controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message. The method can control the flow without designing a lock operation or an atomic operation, so that the method can be deployed in a multi-core processor.

Description

Flow control method, flow control device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of flow control, and in particular, to a flow control method, apparatus, electronic device, and computer readable storage medium.
Background
In order to prevent network congestion when transmitting data in a network, it is necessary to limit the traffic flowing out of the network so that the traffic is sent out at a relatively uniform rate. The token bucket algorithm accomplishes this function, controls the amount of data sent to the network, and allows burst data to be sent.
In the related art, in order to better provide network forwarding services to users under limited bandwidth resources, hardware solutions and software solutions are generally adopted. Among other things, hardware solutions that use dedicated FPGAs (Field-Programmable Gate Array, field programmable gate arrays) or QOS (Quality of Service ) processors (e.g., ezchip network processors) integrated inside the network processor are cost prohibitive. One way that can be implemented in a software solution is to optimize the QoS module provided by DPDK (Data Plane Development Kit, data plane development suite) with code, after which performance comparable to that of a hardware solution can be achieved. Although QOS modules in this implementation can be cost effective, they require stringent deployment requirements (e.g., a kernel must be configured for QOS module use) and cannot be deployed without limitation in flexible and QOS-less scenarios. Another way that software solutions can be implemented is to provide related services using QOS related algorithms (e.g., HTB, hierarchical Token Bucket, hierarchical token bucket algorithms) provided in Linux kernels, but these algorithms are more a product of a compromise that is difficult to satisfy in terms of functionality or performance for network devices.
Disclosure of Invention
An object of an embodiment of the present application is to provide a flow control method, apparatus, electronic device, and computer readable storage medium, which can control flow without designing a lock operation or an atomic operation, so as to be deployed in a multi-core processor.
In a first aspect, an embodiment of the present application provides a flow control method, where the method is applied to a terminal device, and a central processor of the terminal device includes at least two cores, where the method includes: determining the total length of an initial message corresponding to the current period; determining current message data received in total at the current moment, and determining the total length of the current message corresponding to the current message data; determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message; controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message. In this way, the flow can be controlled without designing a lock operation or an atomic operation, so that the flow can be deployed in the multi-core processor.
Optionally, the determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message includes: obtaining the total length of the target message to be sent at the current moment according to the total length of the current message and the total length of the initial message; and determining the target token number according to the total length of the target message. The embodiment of determining the target token number to be consumed according to the total length of the initial message and the total length of the current message is provided, so that the token number which can be consumed in the current period can be conveniently calculated, and whether current limiting is needed or not can be conveniently determined.
Optionally, the determining the total received current message data at the current time and determining the total length of the current message corresponding to the current message data includes: in the period, accumulating the lengths of the single messages corresponding to the single message data received at the current moment by taking the total length of the initial message as a calculation starting point; and accumulating and determining the message length obtained at the period end time as the total length of the current message. Therefore, the total length of the message to be sent in the period can be directly counted, so that the number of target tokens can be calculated periodically, and the purpose of controlling the flow periodically is achieved.
Optionally, the flow control method further comprises: taking the moment of determining the total length of the initial message as a period starting point, and determining the period ending when the preset fixed time length is reached; and determining the total length of the current message received at the end time of the last period as the total length of the initial message of the current period. Therefore, when the total length of the next current message is counted, the total length of the previous current message can be used as an accumulation basis, and even if errors exist in the accumulation basis, the influence on the performance is limited.
Optionally, the preset token bucket has a constant preset capacity, and the flow control method further comprises: storing a fixed number of tokens into the preset token bucket in the period; and if the total number of tokens in the preset token bucket is larger than the preset capacity after the tokens are stored, overflowing redundant tokens. Therefore, redundant tokens can be collected, waste of the tokens is avoided, and the actual utilization rate of the tokens is improved.
Optionally, the preset token bucket includes a guaranteed token bucket for providing tokens of a guaranteed bandwidth and a limited token bucket for providing tokens of a limited bandwidth; and overflowing redundant tokens if the total number of tokens in the preset token bucket is larger than the preset capacity after storing the tokens, including: and preferentially storing tokens in the guaranteed token bucket, and overflowing redundant tokens into the limit token bucket if the total number of the tokens in the guaranteed token bucket is larger than the preset capacity corresponding to the guaranteed token bucket. In this way, on the one hand, tokens required for guaranteeing bandwidth can be provided to meet the requirements, and on the other hand, wasting of tokens can be avoided.
Optionally, the preset token bucket includes a token bucket parent node and at least one token bucket child node, a sum of guaranteed bandwidths corresponding to the at least one token bucket child node is not greater than a guaranteed bandwidth corresponding to the token bucket parent node, and a limited bandwidth corresponding to each of the at least one token bucket child node is not greater than a limited bandwidth corresponding to the token bucket parent node; and the guaranteed token bucket and the limited token bucket are the parent nodes of the token bucket; and controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket, including: determining a token bucket child node of a token to be consumed; indicating the child node of the token bucket to apply for tokens in the guaranteed token bucket when detecting that the receiving rate of the message does not exceed the promised information rate; and applying for tokens in the limiting token bucket when detecting that the receiving rate exceeds the message of the promised information rate. Thus, the preset token bucket is subjected to layering treatment to realize layering control on the flow.
In a second aspect, an embodiment of the present application provides a flow control device, where the flow control device is applied to a terminal device, and a central processor of the terminal device includes at least two cores, where the device includes: the initial determining module is used for determining the total length of the initial message corresponding to the current period; the middle determining module is used for determining the total received current message data at the current moment and determining the total length of the current message corresponding to the current message data; the token number determining module is used for determining the target token number to be consumed according to the total length of the current message and the total length of the initial message; the control module is used for controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message. In this way, the flow can be controlled without designing a lock operation or an atomic operation, so that the flow can be deployed in the multi-core processor.
In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory storing computer readable instructions which, when executed by the processor, perform the steps of the method as provided in the first aspect above.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method as provided in the first aspect above.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the embodiments of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a flow control method according to an embodiment of the present application;
fig. 2 is a schematic diagram of an application scenario of a multi-layer preset token bucket according to an embodiment of the present application;
FIG. 3 is a block diagram of a flow control device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device for executing a flow control method according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance.
It should be noted that embodiments of the present application or technical features of embodiments may be combined without conflict.
In the related art, the hardware solution has the problem of high cost, and the software solution can solve the problem of high cost, but cannot be flexibly deployed in a multi-core scene. In order to solve the problem that the software solution provided in the related art cannot be flexibly deployed in a multi-core scene, the application provides a flow control method, a flow control device, electronic equipment and a computer readable storage medium; further, a message can be periodically sent to the token bucket, and after the token bucket receives the message, the number of tokens to be consumed can be determined according to the total length of the current message accumulated at the current moment, so that whether the message can be directly sent out can be determined according to the number of tokens to be consumed and the total number of tokens in the preset token bucket, and flow control is realized. In this way, if multiple cores exist in the CPU (central processing unit ), the number of tokens to be consumed can be determined through the total length of the initial message and the total length of the current message corresponding to the current period, and then the flow can be controlled according to the number of tokens to be consumed. In the process, the flow control can be flexibly realized without designing a lock operation or an atomic operation, thereby solving the problems.
The above related art solutions have drawbacks, which are results obtained by the inventor after practice and careful study, and therefore, the discovery process of the above problems and the solutions proposed by the embodiments of the present application hereinafter for the above problems should be all contributions of the inventor to the present application in the process of the present application.
Referring to fig. 1, a flow chart of a flow control method according to an embodiment of the application is shown. The flow control method can be applied to terminal equipment, and a central processor of the terminal equipment at least comprises two cores. As shown in fig. 1, the flow control method includes the following steps 101 to 103.
Step 101, determining the total length of the initial message corresponding to the current period.
In some application scenarios, the total length of the initial message corresponding to the current period may be determined first. In these application scenarios, for example, the sent message data may be determined first, and the message length of each sent message data may be accumulated to obtain the total message length, where the total message length may be determined as the initial total message length. In these application scenarios, the total length of the initial message may also be 0. I.e. at this time in the first cycle, the transmission of the message data has not yet been started.
Step 102, determining total received current message data at the current moment, and determining the total length of the current message corresponding to the current message data.
After the terminal device determines the total length of the initial message corresponding to the current period, the terminal device can determine the total received current message data at the current moment. That is, in the current period, the terminal device may further determine the total amount of the received message data at the current time, and determine the corresponding total length of the current message according to the current message data. For example, the total current message data received at the current time includes message data a with a length of 4 bytes and message data B with a length of 6 bytes, and then the total length of the current message may be 10 bytes.
And step 103, determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message.
After determining the total length of the initial message and the total length of the current message, the number of target tokens to be consumed can be determined. In some application scenarios, in order to ensure that the total length of the current message can have a corresponding target token number as much as possible, one or more errors of the message length may be allowed. For example, subtracting the message length of an error value of 4 bytes or 6 bytes on the basis of the total length of the current message, and determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message after subtracting the error value. In these application scenarios, the message length corresponding to the message data to be sent at the current moment in the current period can be determined according to the initial message length, the current message length and the error value, and then the target token number can be determined according to the message length.
104, controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message.
After the target number of tokens is determined, the flow rate can be controlled according to the target number of tokens and the total number of tokens in the preset token bucket. In some application scenarios, for example, the target token number may be compared with the total number of tokens in the preset token bucket, and if the target token number is detected to be not greater than the total number of tokens in the preset token bucket, a message may be sent out all the time. If the number of the target tokens is detected to be larger than the total number of the tokens in the preset token bucket, the sending of the message to the outside can be suspended so as to control the flow.
In the related art, if a token bucket algorithm is to be executed in a processor, a return value needs to be locked to ensure the correctness of the statistically derived traffic. However, the method can only be applied to a single-core processor, and cannot be flexibly applied to a multi-core processor.
In this embodiment, through steps 101 to 104, the flow can be controlled without designing a lock operation or an atomic operation, so that the flow can be deployed in a multi-core processor.
In some application scenarios, there are cases where there is an error in the total length of the current packet, such as due to a delay in reading data from the cache memory and reading data from the memory. However, since no lock operation or atomic operation is configured, the determined total length of the current message is at least the total length of the message closest to the standard current message total length. Therefore, even if an error exists in the total length of the determined current message, the error is within an allowable range, and has limited influence on performance. Then, after application to the multi-core processor, there may be no need to worry about performance impact issues.
In some alternative implementations, the step 103 may include the following sub-steps:
and step 1031, obtaining the total length of the target message to be sent at the current moment according to the total length of the current message and the total length of the initial message.
In some application scenarios, after determining the total length of the initial message and the total length of the current message corresponding to the current period, the two may be subtracted to obtain the total length of the target message to be sent at the current time. For example, after determining that the total length of the initial message is 38 bytes and the total length of the current message is 88 bytes, it may be determined that the total length of the target message to be sent at the current time is 50 bytes.
Sub-step 1032, determining the target token number according to the total length of the target message.
In some application scenarios, the target token number may be further determined after determining the total length of the target message. Here, the technology of determining the number of tokens to be consumed according to the length of the message to be sent is the prior art, which is not described herein.
Through the above-described sub-steps 1031 to 1032, an embodiment is provided in which the target number of tokens to be consumed can be determined based on the total length of the initial message and the total length of the current message, so as to facilitate calculating the number of tokens that may be consumed in the current period, so as to determine whether or not a current limit is required.
In some alternative implementations, the step 102 may include: in the period, accumulating the lengths of the single messages corresponding to the single message data received at the current moment by taking the total length of the initial message as a calculation starting point; and accumulating and determining the message length obtained at the period end time as the total length of the current message.
In some application scenarios, the received lengths of the single messages may be accumulated to obtain the total length of the current message. Specifically, in the same period, the total length of the initial message determined in the period can be used as a calculation starting point, and all message data received by the terminal device in a time period from the period starting time to the current time can be counted. Further, the message length corresponding to each message data may be accumulated, so as to obtain a current message length accumulation sum corresponding to the current time.
In some application scenarios, the sum of the message lengths obtained at the end of the period may be determined as the total length of the current message. That is, in the process of periodically measuring the flow, the sum of the message lengths corresponding to the end time of each period can be determined as the total length of the current message. Therefore, the total length of the message to be sent in the period can be directly counted, so that the number of target tokens can be calculated periodically, and the purpose of controlling the flow periodically is achieved.
In some alternative implementations, the flow control method further includes: taking the moment of determining the total length of the initial message as a period starting point, and determining the period ending when the preset fixed time length is reached; and determining the total length of the current message received at the end time of the last period as the total length of the initial message of the current period.
In some application scenarios, the fixed duration may be a cycle time. For example, 1 second is one cycle. In this way, the time for determining the total length of the initial message can be determined as the starting time of the period, and when the preset fixed time length is reached, the end of the period is determined.
In these application scenarios, the total length of the current message received at the end of the previous period may be determined as the total length of the initial message of the present period. Therefore, when the total length of the next current message is counted, the total length of the previous current message can be used as an accumulation base, and even if errors exist in the accumulation base, the influence on the performance is limited.
In some alternative implementations, the preset token bucket has a constant preset capacity, and the flow control method further includes: storing a fixed number of tokens into the preset token bucket in the period; and if the total number of tokens in the preset token bucket is larger than the preset capacity after the tokens are stored, overflowing redundant tokens.
In some application scenarios, a fixed capacity may be configured for a preset token bucket. For example, the preset capacity of the preset token bucket a may be 100 tokens. In these application scenarios, a fixed number of tokens may be deposited into a preset token bucket per cycle. For example, for the preset token bucket a described above, 100 tokens may be stored therein at the beginning of each cycle.
In these application scenarios, if the total number of tokens in the preset token bucket is greater than the preset capacity of the preset token bucket after the fixed number of tokens are stored in the preset token bucket, redundant tokens may overflow.
In some application scenarios, for example, a plurality of preset token buckets may be set, so that overflowed tokens may be stored in other preset token buckets which are not fully stored, thereby avoiding wasting tokens.
In some alternative implementations, the preset token bucket includes a guaranteed token bucket for providing bandwidth guaranteed tokens and a limited token bucket for providing bandwidth limited tokens; and if the total number of tokens in the preset token bucket is greater than the preset capacity after storing the tokens, overflowing redundant tokens, including: and preferentially storing tokens in the guaranteed token bucket, and overflowing redundant tokens into the limit token bucket if the total number of the tokens in the guaranteed token bucket is larger than the preset capacity corresponding to the guaranteed token bucket.
In some application scenarios, a guaranteed token bucket for carrying a guaranteed bandwidth and a limited token bucket for carrying a limited bandwidth may be provided. Thus, each preset token bucket can provide tokens for corresponding message data at its own discretion.
In these application scenarios, when tokens are stored in the preset token bucket, the tokens may be stored in the guaranteed token bucket preferentially. In this way, the tokens required to guarantee bandwidth can be provided even if the network is very busy.
Further, if the total number of tokens in the guaranteed token bucket is greater than the preset capacity of the guaranteed token bucket after the tokens are stored in the guaranteed token bucket, redundant tokens can be overflowed into the constraint token bucket. In this way, overflow tokens are not wasted.
For example, in period T1, 100 tokens are preferentially stored in a guaranteed token bucket having a preset capacity of 100 token buckets. In the period T1, the determined target number of tokens is 70, and then 30 tokens remain in the guaranteed token bucket in the period T1. At this time, the next period T2 is entered. Similarly, 100 token buckets are preferably stored in the guaranteed token bucket, but since the preset capacity of the guaranteed token bucket is 100 tokens, there are 30 more token buckets after 100 token buckets are stored in the period T2. At this point, the 30 tokens may be overflowed into the restricted token bucket. In this way, on the one hand, tokens required for guaranteeing bandwidth can be provided to meet the requirements, and on the other hand, wasting of tokens can be avoided.
In some optional implementations, the preset token bucket includes a token bucket parent node and at least one token bucket child node, a sum of guaranteed bandwidths corresponding to the at least one token bucket child node is not greater than a guaranteed bandwidth corresponding to the token bucket parent node, and a limited bandwidth corresponding to each of the at least one token bucket child node is not greater than a limited bandwidth corresponding to the token bucket parent node; and the guaranteed token bucket and the restricted token bucket are the parent nodes of the token bucket.
In some application scenarios, the preset token bucket may be configured as a multi-layer token bucket following the HTB algorithm. Specifically, the preset token bucket may include a token bucket parent node and a plurality of token bucket child nodes. At this time, the token bucket parent node may be regarded as a first layer of the preset token bucket, and the token bucket child node may be regarded as a second layer of the preset token bucket, forming a multi-layer structure (as shown in fig. 2).
In some application scenarios, when a plurality of layers of preset token buckets are set, the sum of guaranteed bandwidths corresponding to all the token bucket child nodes is not greater than the guaranteed bandwidth corresponding to the token bucket parent node, so that the token bucket child nodes can always apply for the required tokens from the token bucket parent node. Further, the bandwidth limit corresponding to each token bucket child node may be not greater than the bandwidth limit corresponding to the parent node of the token bucket, so as to limit the traffic corresponding to each token bucket child node.
Thus, the above step 104 may include the sub-steps of:
sub-step 1041, determining a token bucket child node for a token to be consumed;
in some application scenarios, the terminal device may first determine a token bucket child node for which tokens are to be consumed. For example, if other network devices apply for a token from the token bucket sub-node a, the token bucket sub-node a may be determined as the token bucket sub-node to consume the token.
A substep 1042, wherein the token bucket child node is indicated to apply for a token in the guaranteed token bucket when detecting that the receiving rate of the message does not exceed the promised information rate; and applying for tokens in the limiting token bucket when detecting that the receiving rate exceeds the message of the promised information rate.
The above-mentioned committed information rate can be regarded as an information transfer rate in a normal state on a specific virtual circuit predetermined by the network. In some application scenarios, the token bucket child node may be instructed to apply for a token from the guaranteed token bucket when detecting that the receiving rate of the message is smaller than the committed information rate, so as to meet the requirements in the normal state. And the token bucket child node can be instructed to apply for tokens from the limiting token bucket when detecting that the receiving rate of the message is greater than the promised information rate so as to limit the sending rate of the message, thereby achieving the purpose of controlling the flow.
Referring to fig. 2, an application scenario of a multi-layer preset token bucket is shown. The token bucket father node a is a first layer of a preset token bucket, and the token bucket child node b and the token bucket child node c are a second layer of the preset token bucket. And the token bucket parent node a includes a guaranteed token bucket a1 and a restricted token bucket a2. If the guaranteed token bucket a1 stores tokens for providing the guaranteed bandwidth of 10M; the restricted token bucket a2 holds tokens for providing a bandwidth restriction of 20M. Token bucket child node b and token bucket child node c hold tokens for providing bandwidth of (5-20) M.
When both token bucket sub-node b and token bucket sub-node c need to apply for tokens for providing bandwidth of (5-20) M, both token bucket sub-nodes may apply for tokens for providing bandwidth within 5M to guaranteed token bucket a1 and may apply for tokens for providing remaining bandwidth to restricted token bucket a2. The bandwidth-constrained token bucket a2 may determine the object to prioritize tokens based on the time sequence in which the two token bucket child nodes apply for tokens.
When one of the token bucket sub-nodes (e.g., token bucket sub-node b) can provide (5-20) M of bandwidth and the other token bucket sub-node (e.g., token bucket sub-node c) cannot provide bandwidth, a token for transmitting message data within 5M in the token bucket sub-node b can be applied from the guaranteed token bucket a1, and since the guaranteed token bucket a1 can only provide a token for transmitting guaranteed bandwidth of 10M, the token bucket sub-node b can only apply for a token required for limiting bandwidth of 15M from the limited token bucket a2. However, since the token bucket a1 is guaranteed to overflow tokens required for 5M bandwidth into the constraint token bucket a2, the token bucket child node b can apply for tokens required for providing 20M bandwidth without wasting tokens.
Referring to fig. 3, a block diagram of a flow control device, which may be a module, a program segment, or a code on an electronic device, is shown in accordance with an embodiment of the present application. Further, the flow control device can be applied to a terminal device, and a central processor of the terminal device at least comprises two cores. It should be understood that the apparatus corresponds to the embodiment of the method of fig. 1 described above, and is capable of performing the steps involved in the embodiment of the method of fig. 1, and specific functions of the apparatus may be referred to in the foregoing description, and detailed descriptions thereof are omitted herein as appropriate to avoid redundancy.
Optionally, the flow control device includes an initial determination module 301, an intermediate determination module 302, a token number determination module 303, and a control module 304. The initial determining module 301 is configured to determine an initial message total length corresponding to a current period; the middle determining module 302 is configured to determine current message data received in total at a current time, and determine a total length of a current message corresponding to the current message data; the token number determining module 303 is configured to determine a target token number to be consumed according to the total length of the current message and the total length of the initial message; the control module 304 is configured to control a flow corresponding to the target message data according to the target number of tokens and a total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message.
Optionally, the token number determination module 303 is further configured to: obtaining the total length of the target message to be sent at the current moment according to the total length of the current message and the total length of the initial message; and determining the target token number according to the total length of the target message.
Optionally, the intermediate determination module 302 is further configured to: in the period, accumulating the lengths of the single messages corresponding to the single message data received at the current moment by taking the total length of the initial message as a calculation starting point; and accumulating and determining the message length obtained at the period end time as the total length of the current message.
Optionally, the flow control device further includes a reset module, where the reset module is further configured to: taking the moment of determining the total length of the initial message as a period starting point, and determining the period ending when the preset fixed time length is reached; and determining the total length of the current message received at the end time of the last period as the total length of the initial message of the current period.
Optionally, the preset token bucket has a constant preset capacity, and the flow control device further comprises an overflow module, where the overflow module is configured to: storing a fixed number of tokens into the preset token bucket in the period; and if the total number of tokens in the preset token bucket is larger than the preset capacity after the tokens are stored, overflowing redundant tokens.
Optionally, the preset token bucket includes a guaranteed token bucket for providing tokens of a guaranteed bandwidth and a limited token bucket for providing tokens of a limited bandwidth; the overflow module is further to: and preferentially storing tokens in the guaranteed token bucket, and overflowing redundant tokens into the limit token bucket if the total number of the tokens in the guaranteed token bucket is larger than the preset capacity corresponding to the guaranteed token bucket.
Optionally, the preset token bucket includes a token bucket parent node and at least one token bucket child node, a sum of guaranteed bandwidths corresponding to the at least one token bucket child node is not greater than a guaranteed bandwidth corresponding to the token bucket parent node, and a limited bandwidth corresponding to each of the at least one token bucket child node is not greater than a limited bandwidth corresponding to the token bucket parent node; and the guaranteed token bucket and the limited token bucket are the parent nodes of the token bucket; the control module 304 is further configured to: determining a token bucket child node of a token to be consumed; indicating the child node of the token bucket to apply for tokens in the guaranteed token bucket when detecting that the receiving rate of the message does not exceed the promised information rate; and applying for tokens in the limiting token bucket when detecting that the receiving rate exceeds the message of the promised information rate.
It should be noted that, for convenience and brevity, a person skilled in the art will clearly understand that, for the specific working procedure of the apparatus described above, reference may be made to the corresponding procedure in the foregoing method embodiment, and the description will not be repeated here.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device for executing a flow control method according to an embodiment of the present application, where the electronic device may include: at least one processor 401, such as a CPU, at least one communication interface 402, at least one memory 403, and at least one communication bus 404. Wherein the communication bus 404 is used to enable direct connection communication of these components. The communication interface 402 of the device in the embodiment of the present application is used for performing signaling or data communication with other node devices. The memory 403 may be a high-speed RAM memory or a nonvolatile memory (non-volatile memory), such as at least one magnetic disk memory. The memory 403 may also optionally be at least one storage device located remotely from the aforementioned processor. The memory 403 has stored therein computer readable instructions which, when executed by the processor 401, may cause the electronic device to perform the method process described above with reference to fig. 1.
It will be appreciated that the configuration shown in fig. 4 is merely illustrative, and that the electronic device may also include more or fewer components than shown in fig. 4, or have a different configuration than shown in fig. 4. The components shown in fig. 4 may be implemented in hardware, software, or a combination thereof.
Embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, is capable of performing a method procedure performed by an electronic device as in the method embodiment shown in fig. 1.
Embodiments of the present application provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the execution of the methods provided by the method embodiments described above, e.g. the method may comprise: determining the total length of an initial message corresponding to the current period; determining current message data received in total at the current moment, and determining the total length of the current message corresponding to the current message data; determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message; controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; and storing the tokens in the preset token bucket in the same period as the period for determining the total length of the initial message.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (8)

1. A flow control method, applied to a terminal device, where a central processor of the terminal device includes at least two cores, the method comprising:
determining the total length of an initial message corresponding to the current period; the total length of the current message received at the end time of the previous period is determined as the total length of the initial message of the current period;
determining current message data received in total at the current moment, and determining the total length of the current message corresponding to the current message data;
determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message; and
controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket;
wherein, the period of storing tokens in the preset token bucket is the same as the period of determining the total length of the initial message;
the preset token bucket has a constant preset capacity, the preset token bucket including a guaranteed token bucket for providing bandwidth guaranteed tokens and a limited token bucket for providing bandwidth limited tokens, the method further comprising:
storing a fixed number of tokens into the preset token bucket in the period;
and preferentially storing tokens in the guaranteed token bucket, and overflowing redundant tokens into the limit token bucket if the total number of the tokens in the guaranteed token bucket is larger than the preset capacity corresponding to the guaranteed token bucket.
2. The method of claim 1, wherein the determining the number of target tokens to be consumed according to the total length of the current message and the total length of the initial message comprises:
obtaining the total length of the target message to be sent at the current moment according to the total length of the current message and the total length of the initial message;
and determining the target token number according to the total length of the target message.
3. The method of claim 1, wherein the determining the total received current message data at the current time and determining the total length of the current message corresponding to the current message data comprises:
in the period, accumulating the lengths of the single messages corresponding to the single message data received at the current moment by taking the total length of the initial message as a calculation starting point;
and accumulating and determining the message length obtained at the period end time as the total length of the current message.
4. A method according to any one of claims 1-3, wherein the method further comprises:
and taking the moment of determining the total length of the initial message as a period starting point, and determining the period ending when the preset fixed time length is reached.
5. The method of claim 1, wherein the preset token bucket comprises a token bucket parent node and at least one token bucket child node, the sum of guaranteed bandwidths corresponding to the at least one token bucket child node is not greater than the guaranteed bandwidth corresponding to the token bucket parent node, and the limited bandwidth corresponding to each of the at least one token bucket child nodes is not greater than the limited bandwidth corresponding to the token bucket parent node; and the guaranteed token bucket and the limited token bucket are the parent nodes of the token bucket; and
and controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket, including:
determining a token bucket child node of a token to be consumed;
indicating the child node of the token bucket to apply for tokens in the guaranteed token bucket when detecting that the receiving rate of the message does not exceed the promised information rate; and applying for tokens in the limiting token bucket when detecting that the receiving rate exceeds the message of the promised information rate.
6. A flow control device, applied to a terminal device, where a central processor of the terminal device includes at least two cores, comprising:
the initial determining module is used for determining the total length of the initial message corresponding to the current period; the total length of the current message received at the end time of the previous period is determined as the total length of the initial message of the current period;
the middle determining module is used for determining the total received current message data at the current moment and determining the total length of the current message corresponding to the current message data;
the token number determining module is used for determining the target token number to be consumed according to the total length of the current message and the total length of the initial message;
the control module is used for controlling the flow corresponding to the target message data according to the target token number and the total number of tokens in a preset token bucket; wherein, the period of storing tokens in the preset token bucket is the same as the period of determining the total length of the initial message;
the preset token bucket has a constant preset capacity, the preset token bucket comprises a guaranteed token bucket for providing bandwidth-guaranteed tokens and a limited token bucket for providing bandwidth-limited tokens, and the flow control device further comprises an overflow module for: storing a fixed number of tokens into the preset token bucket in the period; and preferentially storing tokens in the guaranteed token bucket, and overflowing redundant tokens into the limit token bucket if the total number of the tokens in the guaranteed token bucket is larger than the preset capacity corresponding to the guaranteed token bucket.
7. An electronic device comprising a processor and a memory storing computer readable instructions that, when executed by the processor, perform the method of any of claims 1-5.
8. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, performs the method according to any of claims 1-5.
CN202111270940.9A 2021-10-29 2021-10-29 Flow control method, flow control device, electronic equipment and computer readable storage medium Active CN113992594B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111270940.9A CN113992594B (en) 2021-10-29 2021-10-29 Flow control method, flow control device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111270940.9A CN113992594B (en) 2021-10-29 2021-10-29 Flow control method, flow control device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN113992594A CN113992594A (en) 2022-01-28
CN113992594B true CN113992594B (en) 2023-11-10

Family

ID=79744287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111270940.9A Active CN113992594B (en) 2021-10-29 2021-10-29 Flow control method, flow control device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113992594B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114785735B (en) * 2022-04-26 2023-09-12 杭州迪普信息技术有限公司 FPGA-based network message current limiting method and device
CN115225580B (en) * 2022-06-10 2024-02-02 新浪技术(中国)有限公司 Service isolation speed limiting method and device for multiprocessor cores
CN115208833B (en) * 2022-07-12 2023-11-28 北京天融信网络安全技术有限公司 Flow control method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106413002A (en) * 2016-11-22 2017-02-15 京信通信技术(广州)有限公司 Terminal velocity control method, terminal velocity control device and terminal velocity control base station
CN106453127A (en) * 2016-11-18 2017-02-22 杭州华三通信技术有限公司 Token processing method and device
CN112187661A (en) * 2020-09-14 2021-01-05 武汉思普崚技术有限公司 QOS flow control method, system, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453127A (en) * 2016-11-18 2017-02-22 杭州华三通信技术有限公司 Token processing method and device
CN106413002A (en) * 2016-11-22 2017-02-15 京信通信技术(广州)有限公司 Terminal velocity control method, terminal velocity control device and terminal velocity control base station
CN112187661A (en) * 2020-09-14 2021-01-05 武汉思普崚技术有限公司 QOS flow control method, system, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"面向多核处理器的令牌一致性协议优化技术研究";付桂涛;《中国博士学位论文全文数据库信息科技辑》(第第2期期);全文 *

Also Published As

Publication number Publication date
CN113992594A (en) 2022-01-28

Similar Documents

Publication Publication Date Title
CN113992594B (en) Flow control method, flow control device, electronic equipment and computer readable storage medium
CN108768873B (en) Flow control method and related equipment
EP3648401B1 (en) Method, device, and computer readable storage medium for managing network slice
US9923965B2 (en) Storage mirroring over wide area network circuits with dynamic on-demand capacity
CN109391505B (en) Network instance management method and related equipment
CN108370341B (en) Resource allocation method, virtual network function manager and network element management system
KR102369305B1 (en) Client transfer method and device
US10419965B1 (en) Distributed meters and statistical meters
CN112214313A (en) Memory allocation method and related equipment
CN111159195A (en) Data storage control method and equipment in block chain system
CN114579296A (en) Server idle calculation scheduling method and device and electronic equipment
CN113032410B (en) Data processing method, device, electronic equipment and computer storage medium
CN108347377B (en) Data forwarding method and device
US10044632B2 (en) Systems and methods for adaptive credit-based flow
CN114500381A (en) Network bandwidth limiting method, system, electronic device and readable storage medium
CN113906720B (en) Traffic scheduling method, traffic scheduling device and storage medium
CN110245013B (en) Internet of Things computing resource management method and device
CN113453285B (en) Resource adjusting method, device and storage medium
CN111131083B (en) Method, device and equipment for data transmission between nodes and computer readable storage medium
CN110162415B (en) Method, server, device and storage medium for processing data request
CN109491948B (en) Data processing method and device for double ports of solid state disk
CN113162990B (en) Message sending method, device, equipment and storage medium
CN112422613B (en) Data processing method, data processing platform and computer readable storage medium
JP6502134B2 (en) Data transmission control device, data transmission control method, and program
CN114244744B (en) Node discovery method and device based on Internet of things equipment

Legal Events

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