CN101557348B - A message forwarding method and device based on token bucket - Google Patents
A message forwarding method and device based on token bucket Download PDFInfo
- Publication number
- CN101557348B CN101557348B CN2009101433911A CN200910143391A CN101557348B CN 101557348 B CN101557348 B CN 101557348B CN 2009101433911 A CN2009101433911 A CN 2009101433911A CN 200910143391 A CN200910143391 A CN 200910143391A CN 101557348 B CN101557348 B CN 101557348B
- Authority
- CN
- China
- Prior art keywords
- token bucket
- message
- priority
- capacity
- token
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明涉及一种基于令牌桶的报文转发方法及装置,该方法包括基于优先级设置令牌桶,每个不同优先级令牌桶初始化容量为全部可用带宽;当接收到某一优先级的报文时,查找与该报文相匹配的令牌桶进行报文转发,如果该优先级令牌桶中的令牌数满足转发该报文的要求,则对该报文进行转发;同时更新该优先级令牌桶以及较低优先级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,并将所述该优先级令牌桶以及较低优先级令牌桶更新后的令牌桶容量作为其当前容量。本发明实现复杂度低,效率高,并且易扩展优先级。
The present invention relates to a message forwarding method and device based on token buckets. The method includes setting token buckets based on priorities, and the initial capacity of each token bucket with different priorities is the entire available bandwidth; When sending a message, search for the token bucket that matches the message and forward the message, if the number of tokens in the priority token bucket meets the requirements for forwarding the message, then forward the message; at the same time Update the capacity of the priority token bucket and the lower priority token bucket to its current capacity minus the number of tokens used to forward the message, and set the priority token bucket and the lower priority token bucket The updated token bucket capacity of the card bucket is used as its current capacity. The invention has low implementation complexity, high efficiency and easy expansion of priority.
Description
技术领域 technical field
本发明涉及通信领域,尤其涉及一种基于令牌桶的报文转发方法及装置。The invention relates to the communication field, in particular to a token bucket-based message forwarding method and device.
背景技术 Background technique
在通信网络中,通常将不同实时业务分成不同的优先级业务进行转发,以保证高优先级的带宽需求。现有技术中,主要采用两种方法来实现上述不同业务的带宽管理和优先级管理,一种是CBQ(Class Based Queuing,基于类的队列)技术,该技术主要通过不同优先级的队列按照使用不同的调度及检测,确保高优先级的报文得以快速转发,而低优先级的报文也可以拥有可控的时延。但由于上述方法是通过队列来实现,需要缓存大量的报文,因此占用大量的内存,对于一些小型的如无线接入设备内存偏低的产品来说,其内存很难满足要求;并且,上述方法的队列调度算法复杂且运行效率差,如果新增一种优先级,则需要对整个队列结构进行调整,因此该方法的扩展性也比较差。In a communication network, different real-time services are usually divided into different priority services for forwarding, so as to ensure high-priority bandwidth requirements. In the prior art, two methods are mainly used to realize the bandwidth management and priority management of the above-mentioned different services. One is CBQ (Class Based Queuing, class-based queue) technology, which mainly uses different priority queues according to the usage Different scheduling and detection ensure that high-priority packets can be forwarded quickly, while low-priority packets can also have controllable delay. However, because the above method is implemented through queues, a large amount of messages need to be cached, so it takes up a large amount of memory. For some small products such as wireless access devices with low memory, the memory is difficult to meet the requirements; and, the above The queue scheduling algorithm of the method is complex and the operating efficiency is poor. If a new priority is added, the entire queue structure needs to be adjusted, so the scalability of the method is relatively poor.
另一种是使用令牌桶技术,实现方式上又分为下面几种方式:The other is to use the token bucket technology, which is divided into the following ways in terms of implementation:
一种方式为设置一令牌桶给低优先级的普通业务,高优先级业务不需要消耗令牌,从而实现将低优先级普通业务的转发速度控制在一定阈值范围内,来保证高优先级业务的带宽需求,该方法缺陷是限速阈值不好界定,过高造成带宽利用率低,过低又不能保证高优先级业务的带宽需求;One way is to set a token bucket for low-priority common services, high-priority services do not need to consume tokens, so as to control the forwarding speed of low-priority common services within a certain threshold range to ensure high-priority The bandwidth requirements of the business, the defect of this method is that the speed limit threshold is not well defined, if it is too high, the bandwidth utilization rate will be low, and if it is too low, it will not be able to guarantee the bandwidth requirements of high-priority services;
另一种方式为普通优先级和高优先级的业务报文都设置令牌桶,当令牌桶中的令牌数小于待转发的数据包所需要的令牌数时,根据待转发的数据包是否为高优先级的数据包对其进行相应的处理,是则对其进行转发处理,并计令牌桶中可以使用的令牌数为负值,否则,丢弃待处理的数据包,该方法虽然从整体上能够降低普通优先级业务对线路带宽的占用,从而保证了高优先级业务的带宽需求,但是也是牺牲了带宽利用率,尤其是在带宽紧张的时候,不能很好地保证高优先级业务的带宽需求;Another way is to set token buckets for both normal priority and high priority service packets. When the number of tokens in the token bucket is less than the number of tokens required by the data packets to be forwarded, the Whether the packet is a high-priority data packet is processed accordingly. If it is, it is forwarded and the number of tokens that can be used in the token bucket is counted as a negative value. Otherwise, the pending data packet is discarded. Although the method can reduce the line bandwidth occupied by ordinary priority services as a whole, thereby ensuring the bandwidth requirements of high priority services, it also sacrifices bandwidth utilization, especially when the bandwidth is tight, and cannot guarantee high Bandwidth requirements for priority services;
再有一种方式是定时监测高优先级业务的实际使用带宽来调整普通优先级业务令牌桶的更新速率,高优先级和低优先级的令牌桶的带宽之和为全部可用带宽,该方法实质上是通过限制普通优先级业务的带宽来改善高优先级业务的带宽,与上述两种方式在改善带宽利用率和保证高优先级业务的带宽上并没有太大的提高,并且需要不断地监测高优先级的带宽,实现起来比较麻烦。Another way is to periodically monitor the actual bandwidth used by high-priority services to adjust the update rate of token buckets for ordinary priority services. The sum of the bandwidths of high-priority and low-priority token buckets is the total available bandwidth. In essence, it improves the bandwidth of high-priority services by limiting the bandwidth of ordinary priority services. Compared with the above two methods, there is not much improvement in improving bandwidth utilization and ensuring the bandwidth of high-priority services. Monitoring high-priority bandwidth is cumbersome to implement.
综上所述,现有技术中的对报文带宽需求管理方法存在着无法合理进行带宽分配,带宽利用率低和无法有效保证高优先级业务的带宽需求的缺点。To sum up, the methods for managing packet bandwidth requirements in the prior art have the disadvantages of being unable to allocate bandwidth reasonably, having low bandwidth utilization, and being unable to effectively guarantee the bandwidth requirements of high-priority services.
发明内容 Contents of the invention
为了解决上述问题,本发明的目的是提供一种具有高效带宽管理、低复杂度和易扩展优先级的报文转发方法及装置。In order to solve the above problems, the purpose of the present invention is to provide a message forwarding method and device with efficient bandwidth management, low complexity and easy extensible priority.
为实现上述目的,本发明提供了一种基于令牌桶的报文转发方法,包括:To achieve the above object, the present invention provides a token bucket-based message forwarding method, comprising:
基于优先级设置令牌桶,每个不同优先级令牌桶初始化容量为全部可用带宽;Token buckets are set based on priority, and the initial capacity of each token bucket with different priorities is the full available bandwidth;
当接收到某一优先级的报文时,查找与该报文相匹配的令牌桶进行报文转发,如果该优先级令牌桶中的令牌数满足转发该报文的要求,则对该报文进行转发;When receiving a message of a certain priority, look for the token bucket that matches the message and forward the message. If the number of tokens in the priority token bucket meets the requirements for forwarding the message, then The message is forwarded;
同时更新该优先级令牌桶以及较低优先级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,并将所述该优先级令牌桶以及较低优先级令牌桶更新后的令牌桶容量作为其当前容量。At the same time, the capacity of the priority token bucket and the lower priority token bucket is updated to its current capacity minus the number of tokens used to forward the message, and the priority token bucket and lower priority The updated token bucket capacity of the token bucket is its current capacity.
所述方法还包括:如果检测该优先级令牌桶中的令牌数不满足报文转发的要求,则丢弃该报文。The method further includes: discarding the message if it is detected that the number of tokens in the priority token bucket does not meet the requirements for message forwarding.
所述基于优先级设置令牌桶包括:The priority-based setting token bucket includes:
将某一优先级的令牌桶设置为单层令牌桶,所述单层令牌桶为一级令牌桶,其容量初始化为全部可用带宽;The token bucket of a certain priority is set as a single-layer token bucket, and the single-layer token bucket is a first-level token bucket, and its capacity is initialized to all available bandwidth;
或将某一优先级的令牌桶设置为双层令牌桶,所述双层令牌桶包括一级令牌桶和分别与该优先级内不同类型报文相匹配的多个二级令牌桶,所述一级令牌桶初始化容量为全部可用带宽,所述多个二级令牌桶容量之和等于所述一级令牌桶的容量。Or set the token bucket of a certain priority as a double-layer token bucket, the double-layer token bucket includes a first-level token bucket and a plurality of second-level token buckets that are respectively matched with different types of messages in this priority The card bucket, the initial capacity of the first-level token bucket is all available bandwidth, and the sum of the capacities of the multiple second-level token buckets is equal to the capacity of the first-level token bucket.
当查找与该报文相匹配的令牌桶为二级令牌桶时,检测该二级令牌桶中的令牌数是否满足转发该报文的要求,是则对该报文进行转发;否则,进一步检测该优先级一级令牌桶中的令牌数是否满足转发该报文的要求,是则进行报文转发。When finding that the token bucket matching the message is a secondary token bucket, detect whether the number of tokens in the secondary token bucket meets the requirements for forwarding the message, and if so, forward the message; Otherwise, it is further detected whether the number of tokens in the token bucket of the first level of priority meets the requirements for forwarding the message, and if so, the message is forwarded.
所述更新该优先级令牌桶在该优先级令牌桶为双层令牌桶时具体为:The update of the priority token bucket is specifically as follows when the priority token bucket is a double-layer token bucket:
更新该报文相匹配的二级令牌桶和该优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,并将所述该二级令牌桶和该一级令牌桶更新后的令牌桶容量为其当前容量。Update the capacity of the second-level token bucket matching the message and the priority first-level token bucket to its current capacity minus the number of tokens used to forward the message, and set the second-level token bucket and the updated token bucket capacity of the first-level token bucket is its current capacity.
所述更新较低优先级令牌桶在较低优先级令牌桶为双层令牌桶时具体为:The update of the lower priority token bucket is specifically as follows when the lower priority token bucket is a double-layer token bucket:
更新该较低优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数;Update the capacity of the lower-priority first-level token bucket to its current capacity minus the number of tokens used to forward the message;
更新该较低优先级内每个二级令牌桶的容量为其当前容量减去相应比例的转发该报文所使用的令牌数,所述相应比例为每个二级令牌桶与该较低优先级一级令牌桶的容量比;Update the capacity of each secondary token bucket in the lower priority level to its current capacity minus the corresponding proportion of the number of tokens used to forward the message. The corresponding ratio is the ratio of each secondary token bucket to the The capacity ratio of the lower priority first-level token bucket;
并将所述该较低优先级中二级令牌桶和一级令牌桶更新后的令牌桶容量为其当前容量。And the updated token bucket capacity of the second-level token bucket and the first-level token bucket in the lower priority is its current capacity.
本发明还提供一种基于令牌桶的报文转发装置,其特征在于,所述装置包括:The present invention also provides a token bucket-based message forwarding device, characterized in that the device includes:
令牌桶设置单元,用于基于优先级设置令牌桶,每个不同优先级令牌桶初始化容量为全部可用带宽;The token bucket setting unit is used to set the token bucket based on priority, and the initial capacity of each token bucket with different priority is the full available bandwidth;
检测转发单元,用于当接收到某一优先级的报文时,采用与该报文相匹配的令牌桶进行报文转发,如果该令牌桶中的令牌数满足转发该报文的要求,则对该报文进行转发,否则丢弃该报文,同时触发更新单元;The detection forwarding unit is used for forwarding the message by using the token bucket matching the message when receiving a message of a certain priority, if the number of tokens in the token bucket satisfies the requirements for forwarding the message If required, the packet is forwarded; otherwise, the packet is discarded, and an update unit is triggered at the same time;
更新单元,用于更新该优先级令牌桶以及较低优先级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,所述该优先级令牌桶以及较低优先级令牌桶的当前容量为其更新后的令牌桶容量。The update unit is used to update the capacity of the priority token bucket and the lower priority token bucket to its current capacity minus the number of tokens used to forward the message, the priority token bucket and the lower priority token bucket The current capacity of the priority token bucket is its updated capacity.
所述令牌桶设置单元包括:The token bucket setting unit includes:
单层令牌桶设置模块,用于将某一优先级的令牌桶设置为单层令牌桶,所述单层令牌桶为一级令牌桶,其容量初始化为全部可用带宽;和/或A single-level token bucket setting module, configured to set a certain priority token bucket as a single-level token bucket, the single-level token bucket is a first-level token bucket, and its capacity is initialized to all available bandwidth; and /or
双层令牌桶设置模块,用于将某一优先级的令牌桶设置为双层令牌桶,所述双层令牌桶包括一级令牌桶和分别与该优先级内不同类型报文相匹配的多个二级令牌桶,所述一级令牌桶初始化容量为全部可用带宽,所述多个二级令牌桶容量之和等于所述一级令牌桶的容量。The double-layer token bucket setting module is used to set the token bucket of a certain priority level as a double-layer token bucket, and the double-layer token bucket includes a first-level token bucket and a The initial capacity of the first-level token bucket is all available bandwidth, and the sum of the capacities of the multiple second-level token buckets is equal to the capacity of the first-level token bucket.
所述检测转发单元还包括:The detection forwarding unit also includes:
第一检测转发模块,用于当所述与该报文相匹配的令牌桶为二级令牌桶时,检测该二级令牌桶中的令牌数是否满足转发该报文的要求,是则对该报文进行转发;否则,进一步检测该优先级一级令牌桶中的令牌数是否满足转发该报文的要求,是则进行报文转发,否则丢弃该报文。The first detection and forwarding module is used to detect whether the number of tokens in the second-level token bucket meets the requirements for forwarding the message when the token bucket matching the message is a second-level token bucket, If yes, the message is forwarded; otherwise, it is further detected whether the number of tokens in the token bucket of the priority level meets the requirements for forwarding the message, and if so, the message is forwarded, otherwise, the message is discarded.
所述更新单元包括:本优先级更新模块,用于在该优先级令牌桶为双层令牌桶时更新该报文相匹配的二级令牌桶和该优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,并将所述该二级令牌桶和该一级令牌桶更新后的令牌桶容量为其当前容量。The update unit includes: this priority update module, which is used to update the two-level token bucket matching the message and the first-level token bucket of the priority when the priority token bucket is a double-layer token bucket. The capacity is its current capacity minus the number of tokens used for forwarding the message, and the capacity of the token bucket after updating the secondary token bucket and the primary token bucket is its current capacity.
所述更新单元包括:The update unit includes:
低优先级更新模块,用于在较优先级令牌桶为双层令牌桶时更新该较低优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,以及更新该较低优先级内每个二级令牌桶的容量为其当前容量减去相应比例的转发该报文所使用的令牌数,其中所述相应比例为每个二级令牌桶与该较低优先级一级令牌桶的容量比,并将所述该较低优先级中二级令牌桶和一级令牌桶更新后的令牌桶容量为其当前容量。A low-priority update module, configured to update the lower-priority first-level token bucket when the higher-priority token bucket is a double-layer token bucket. The capacity of the lower-priority first-level token bucket is its current capacity minus the token used to forward the message number, and update the capacity of each secondary token bucket in the lower priority level to its current capacity minus the corresponding proportion of the number of tokens used to forward the message, wherein the corresponding proportion is the number of tokens used by each secondary order The capacity ratio of the card bucket to the lower priority first-level token bucket, and the updated token bucket capacity of the lower-priority second-level token bucket and the first-level token bucket as its current capacity.
由上述技术方案可知,本发明采用全局设置令牌桶的方式在对报文进行转发时,所有优先级的令牌桶都占用全部可用带宽,从而能够最大化利用带宽,并且在使用高优先级令牌桶进行报文转发时,更新其低优先级令牌桶的带宽,从而保证了高优先级的报文相对于低优先级的报文能够绝对转发。本发明实现复杂度低,效率高,而且能够动态地增加和删除优先级,而仅需增加一层一级令牌桶或二级令牌桶就可实现,具有无限的扩展能力。It can be seen from the above technical solution that when the present invention forwards messages by setting token buckets globally, the token buckets of all priorities occupy all available bandwidth, thereby maximizing the use of bandwidth, and when using high-priority When the token bucket forwards packets, it updates the bandwidth of its low-priority token bucket, thus ensuring that high-priority packets can be absolutely forwarded relative to low-priority packets. The present invention has low implementation complexity and high efficiency, and can dynamically increase and delete priorities, and can be realized only by adding a first-level token bucket or a second-level token bucket, and has unlimited expansion capability.
通过以下参照附图对优选实施例的说明,本发明的上述以及其它目的、特征和优点将更加明显。The above and other objects, features and advantages of the present invention will be more apparent through the following description of preferred embodiments with reference to the accompanying drawings.
附图说明 Description of drawings
图1为本发明的令牌桶的分类方法示意图;Fig. 1 is the schematic diagram of the classification method of the token bucket of the present invention;
图2为本发明的基于令牌桶的报文转发方法的流程图;Fig. 2 is the flowchart of the message forwarding method based on the token bucket of the present invention;
图3为本发明的一个实施例令牌桶的结构示意图;Fig. 3 is a schematic structural diagram of a token bucket according to an embodiment of the present invention;
图4为本发明的一种基于令牌通的报文转发装置结构框图。FIG. 4 is a structural block diagram of a token-based message forwarding device according to the present invention.
具体实施方式 Detailed ways
下面将详细描述本发明的具体实施例。应当注意,这里描述的实施例只用于举例说明,并不用于限制本发明。Specific embodiments of the present invention will be described in detail below. It should be noted that the embodiments described here are for illustration only, and are not intended to limit the present invention.
本发明的构思是在基于报文分类的基础上,采用全局设置和更新令牌桶的方式对报文进行转发,以使最大化利用带宽和保证高优先级的带宽需求。The idea of the present invention is to forward the message by globally setting and updating the token bucket on the basis of message classification, so as to maximize bandwidth utilization and ensure high-priority bandwidth requirements.
具体地,本发明基于优先级设置令牌桶,按照优先级的高低分别设置不同优先级的令牌桶,每个优先级的令牌桶的初始化容量都为全部可用带宽,也就是说,在初始阶段,无论哪一个优先级的报文到来时都会拥有全部可用带宽。Specifically, the present invention sets token buckets based on priorities, and respectively sets token buckets of different priorities according to the priority level. The initial capacity of token buckets of each priority level is all available bandwidth, that is to say, in In the initial stage, no matter which priority packet arrives, it will have all the available bandwidth.
当某一优先级的报文到来时,经过相应优先级的令牌桶,检测该优先级令牌桶令牌数是否满足转发报文的要求,若满足,则从该优先级令牌桶内取走相应数量的令牌,对该报文进行转发。When a message of a certain priority arrives, it passes through the token bucket of the corresponding priority to check whether the number of tokens in the priority token bucket meets the requirements for forwarding the message. Take away the corresponding number of tokens and forward the message.
若该优先级令牌桶中的令牌数不满足转发该报文的要求,一般情况下,则丢弃该报文。If the number of tokens in the priority token bucket does not meet the requirements for forwarding the message, in general, the message is discarded.
在上述转发报文的同时,更新该优先级令牌桶和较低优先级令牌桶的容量,该优先级令牌桶和较低优先级令牌桶的容量更新为其当前容量减去所述相应数量的令牌数,然后该优先级令牌桶和较低优先级令牌桶更新后的容量为其当前容量。这样的更新方式对于本优先级的报文来说,在转发该报文时,较低优先级的报文不会占用该报文的带宽,而对于低优先级的报文来说,只能占用高优先级不用的剩余带宽,从而保证了高优先级报文相对于低优先级报文的绝对转发,最大化地利用了带宽。While forwarding the message above, update the capacity of the priority token bucket and the lower priority token bucket, the capacity of the priority token bucket and the lower priority token bucket is updated to its current capacity minus the The corresponding number of tokens mentioned above, and then the updated capacity of the priority token bucket and the lower priority token bucket is its current capacity. In such an update method, for a message of this priority, when the message is forwarded, a message of a lower priority will not occupy the bandwidth of the message, but for a message of a lower priority, only Occupies the remaining bandwidth that is not used by high priority, thus ensuring the absolute forwarding of high priority packets relative to low priority packets, and maximizing the use of bandwidth.
进一步地对于某一优先级的报文来说,又可分为不同类型的报文,因此,本发明又可将某个优先级的令牌桶设置成与报文类型相匹配的单层令牌桶或双层令牌桶,所述单层令牌桶为一级令牌桶,所述双层令牌桶包括一级令牌桶和多个二级令牌桶,其中一级令牌桶占用全部可用带宽,多个二级令牌桶的带宽之和等于同一优先级一级令牌桶的带宽。如图1所示,高优先级报文所采用的是只有一级令牌桶的单层令牌桶,较低优先级报文所采用的是包括一个一级令牌桶和三个二级令牌桶的双层令牌桶;当然,也可以反之设置,高优先级报文采用双层令牌桶,较低优先级报文采用单层令牌桶。Further, for a message of a certain priority, it can be divided into different types of messages. Therefore, the present invention can set the token bucket of a certain priority as a single-layer token bucket matching the message type. card bucket or double-layer token bucket, the single-layer token bucket is a first-level token bucket, and the double-layer token bucket includes a first-level token bucket and multiple second-level token buckets, wherein the first-level token bucket The bucket occupies all the available bandwidth, and the sum of the bandwidth of multiple second-level token buckets is equal to the bandwidth of the first-level token bucket of the same priority. As shown in Figure 1, high-priority packets use a single-level token bucket with only one level token bucket, and lower-priority packets use a single-level token bucket and three Double-layer token buckets of token buckets; of course, it can also be set in reverse, high-priority packets use double-layer token buckets, and lower-priority packets use single-layer token buckets.
其中某个优先级令牌桶的设置方式依据报文类型而定,比如说该优先级内需要匹配四种类型的报文,那么该优先级别内的令牌桶就可以分为一个一级令牌桶和四个与报文类型匹配的二级令牌桶,这里双层令牌桶中的一级令牌桶的设置就是为了合理分配带宽给其同一优先级别内的二级令牌桶,该一级令牌桶是个虚拟的令牌桶,在进行报文转发时,并不实际存在。如果该优先级别内只有一种报文类型,只需设定一个一级令牌桶即可。The setting method of a certain priority token bucket depends on the packet type. For example, if four types of packets need to be matched in this priority level, then the token buckets in this priority level can be divided into a first-level token bucket. card bucket and four second-level token buckets that match the message type. Here, the first-level token bucket in the double-layer token bucket is set to reasonably allocate bandwidth to the second-level token bucket in the same priority level. The first-level token bucket is a virtual token bucket, which does not actually exist when packets are forwarded. If there is only one packet type in this priority class, only one first-level token bucket needs to be set.
本发明采用上述分类的令牌桶在对不同类别的报文进行转发时,按照以下流程对报文进行转发,如图2所示:When the present invention adopts the above-mentioned classified token bucket to forward messages of different types, the messages are forwarded according to the following process, as shown in Figure 2:
1、报文经过分类器进入其匹配的令牌桶中;1. The message enters the matching token bucket through the classifier;
2、检测所匹配令牌桶中的令牌数是否满足报文进行转发处理所需要的令牌数,是则就进行转发处理。根据不同形式的匹配令牌桶,上述检测方式也不同:2. Detect whether the number of tokens in the matched token bucket meets the number of tokens required for forwarding processing of the message, and if so, perform forwarding processing. According to different forms of matching token buckets, the above detection methods are also different:
如果匹配的是一级令牌桶,其中的令牌数若满足要求,则直接进行转发处理;If the match is a first-level token bucket, if the number of tokens in it meets the requirements, it will be forwarded directly;
如果匹配的是二级令牌桶,其中的令牌数若满足要求,则直接进行转发处理,若不满足要求,需要进一步地检测其对应的一级令牌桶是否满足报文转发所需要的令牌数,如果其对应的一级令牌桶满足要求,则对该报文进行转发处理;If the match is a second-level token bucket, if the number of tokens in it meets the requirements, it will be forwarded directly. If it does not meet the requirements, it is necessary to further check whether the corresponding first-level token bucket meets the requirements for message forwarding. The number of tokens. If the corresponding first-level token bucket meets the requirements, the message will be forwarded;
3、在上述检测通过,转发报文的同时,需要更新转发报文所采用的令牌桶及其优先级的令牌桶的容量,其更新方式依据双层令牌桶和单层令牌桶而不同:3. When the above test is passed and the message is forwarded, the token bucket used for forwarding the message and the capacity of the token bucket with priority need to be updated. The update method is based on the double-layer token bucket and single-layer token bucket Instead of:
若匹配的是一级令牌桶,在转发报文的同时更新该一级令牌桶的令牌数和较低优先级令牌桶的令牌数,更新后的容量为其当前容量减去转发报文所需要的容量,然后当下一个报文到来时,该一级令牌桶的令牌数和较低优先级令牌桶的当前容量为转发该报文更新后的容量。若匹配的是二级令牌桶,不管是该二级令牌桶还是其对应的一级令牌桶满足转发报文所需要的令牌数,在转发报文的同时都需要更新该二级令牌桶、对应的一级令牌桶以及较低优先级令牌桶的容量,更新后的该二级令牌桶、该优先级一级令牌桶以及较低优先级令牌桶的容量为其当前容量减去转发报文所需要的令牌数,然后当下一个报文到来时,该二级令牌桶、该优先级一级令牌桶和较低优先级令牌桶的当前容量为转发该报文更新后的容量。If the match is a first-level token bucket, update the number of tokens in the first-level token bucket and the number of tokens in the lower-priority token bucket while forwarding the message, and the updated capacity is its current capacity minus The capacity required for forwarding a message, and then when the next message arrives, the number of tokens in the first-level token bucket and the current capacity of the lower priority token bucket are the updated capacity for forwarding the message. If the match is a second-level token bucket, no matter whether the second-level token bucket or its corresponding first-level token bucket meets the number of tokens required for forwarding the message, the second-level token bucket needs to be updated when the message is forwarded. The capacity of the token bucket, the corresponding first-level token bucket, and the lower-priority token bucket, and the updated capacity of the second-level token bucket, the first-level token bucket of the priority, and the lower-priority token bucket Subtract the number of tokens required to forward the message from its current capacity, and then when the next message arrives, the current capacity of the second-level token bucket, the first-level token bucket of this priority, and the lower-priority token bucket The updated capacity for forwarding the message.
其中这里在更新较低优先级令牌桶时,如果该较低优先级令牌桶为双层令牌桶,该较低优先级一级令牌桶的容量更新为其当前容量减去转发报文所需要的令牌数,而该较低优先级二级令牌桶按照其容量与该较低优先级一级令牌桶容量比例来进行更新,更新后的容量为其当前容量减去相应比例的用于报文转发的令牌数。Wherein, when updating the lower priority token bucket, if the lower priority token bucket is a double-layer token bucket, the capacity of the lower priority first-level token bucket is updated to its current capacity minus the forwarding report The number of tokens required by the text, and the lower priority secondary token bucket is updated according to the ratio of its capacity to the lower priority primary token bucket capacity, and the updated capacity is its current capacity minus the corresponding Proportional number of tokens used for message forwarding.
这样的更新方式保证了高优先级的报文优先转发,而低优先级的报文只能占用高优先级报文不需要的剩余带宽;This update method ensures that high-priority packets are forwarded first, while low-priority packets can only occupy the remaining bandwidth that high-priority packets do not need;
上面概述了本发明在转发报文时所采用的基本技术方案,下面从结合图1-3的一个具体实施例来进一步地解释本发明的技术方案,在该实施例中,所采用的令牌桶包括单层令牌桶或多层令牌桶。The basic technical solution adopted by the present invention when forwarding messages has been outlined above, and the technical solution of the present invention will be further explained below in conjunction with a specific embodiment of Fig. 1-3. In this embodiment, the token used Buckets include single-level token buckets or multi-level token buckets.
假设进行报文转发全部可用带宽为20M,从高优先级到低优先级的所有一级令牌桶的容量都为20M,如图3所示,示例出从高到低三个优先级的令牌桶,高优先级的令牌桶只有一个一级令牌桶A,较低优先级的令牌桶包括一级令牌桶和二级令牌桶。对于单层令牌桶来说,上述在报文转发时对令牌桶的检测更新过程是一次计算过程,而双层令牌桶则是一次或两次的检测更新:Assume that the total available bandwidth for message forwarding is 20M, and the capacity of all first-level token buckets from high priority to low priority is 20M, as shown in Figure 3, an example of token buckets with three priorities from high to low Card buckets, the high priority token bucket has only one first-level token bucket A, and the lower priority token buckets include the first-level token bucket and the second-level token bucket. For a single-layer token bucket, the above-mentioned detection and update process of the token bucket during message forwarding is a calculation process, while a double-layer token bucket is one or two detection updates:
(1)双层令牌桶的检测更新(1) Detection update of double-layer token bucket
假设某个优先级内令牌桶包括一级令牌桶E,三个二级令牌桶B、C和D,其中一级令牌桶E的带宽为总带宽20M,等于二级令牌桶B、C和D带宽之和,这里二级令牌桶B、C和D的带宽分别为10M、5M和5M。Assume that the token buckets in a certain priority include a first-level token bucket E, three second-level token buckets B, C and D, and the bandwidth of the first-level token bucket E is a total bandwidth of 20M, which is equal to the second-level token bucket The sum of the bandwidths of B, C, and D, where the bandwidths of the secondary token buckets B, C, and D are 10M, 5M, and 5M, respectively.
当有匹配类型B的报文经过令牌桶时,先计算二级令牌桶B中的令牌数是否满足要求。When a message matching type B passes through the token bucket, it first calculates whether the number of tokens in the secondary token bucket B meets the requirements.
如果当前二级令牌桶B中的令牌数满足要求,则更新令牌桶B的相应令牌数,这里假设每个令牌允许发送一个字节的报文,也就是从令牌桶中减去相应于报文数据量的令牌数,同时也对令牌桶B对应的一级令牌桶E进行更新,减去相应于报文数据量的令牌数。此时,同一优先级内的二级令牌桶C和D所能使用的总带宽就减少相应于报文数据量的带宽,这样在更新二级令牌桶的同时也对其对应一级令牌桶进行更新的方式,使该二级令牌桶在转发报文时总能保持至少有10M的流量。If the number of tokens in the current secondary token bucket B meets the requirements, update the corresponding number of tokens in token bucket B. Here, it is assumed that each token is allowed to send a byte of message, that is, from the token bucket Subtract the number of tokens corresponding to the amount of message data, and at the same time update the first-level token bucket E corresponding to token bucket B, and subtract the number of tokens corresponding to the amount of message data. At this time, the total bandwidth that can be used by the secondary token buckets C and D in the same priority is reduced by the bandwidth corresponding to the amount of message data, so that when the secondary token bucket is updated, it also corresponds to the primary token bucket. The way the token bucket is updated, so that the secondary token bucket can always maintain at least 10M of traffic when forwarding messages.
如果当前二级令牌桶B中的令牌数不满足要求,则进一步地检测其对应的一级令牌桶E中的令牌数是否满足要求,若此时令牌桶E满足要求,同样地对该匹配类型B的报文进行转发,也就是在转发该报文时从一级令牌桶E中取走令牌桶B中不足部分的令牌数,这说明此时匹配类型C和D的报文并没有达到转发的限速上限,从而保证了在带宽空闲时,同一优先级别内的不同类型报文可以尽可能最大化利用带宽。在此情况下,同样也要更新令牌桶E的令牌数。If the number of tokens in the current secondary token bucket B does not meet the requirements, then further check whether the token number in the corresponding primary token bucket E meets the requirements, if the token bucket E meets the requirements at this time, the same Forward the message matching type B, that is, take away the insufficient token number in token bucket B from the first-level token bucket E when forwarding the message, which means that matching type C and The packet of D does not reach the upper limit of the forwarding rate, thus ensuring that when the bandwidth is idle, different types of packets in the same priority level can use the bandwidth as much as possible. In this case, the number of tokens in the token bucket E must also be updated.
并且,在上述两种情况下,除了对令牌桶E的更新,还要同时更新其低优先级的所有令牌桶的令牌数,即令牌桶F、令牌桶G以及令牌桶H。假设上述报文的为1M,则一级令牌桶H应减少1M的令牌数,而二级令牌桶G和H按照当前级别其占用的令牌数比例进行更新,其中二级令牌桶F减少1M*(5M/20M)=1/4M,二级令牌桶G减少1M*(15M/20M)=3/4M。这样确保高优先级报文类型B转发时,低优先级类型F和G的报文只能占用剩余带宽,从而实现了高优先级的绝对转发。And, in the above two cases, in addition to updating the token bucket E, the number of tokens in all token buckets with low priority must be updated at the same time, that is, token bucket F, token bucket G, and token bucket H. Assuming that the above-mentioned message is 1M, the number of tokens in the first-level token bucket H should be reduced by 1M, and the second-level token buckets G and H should be updated according to the proportion of the number of tokens occupied by them at the current level. The bucket F is reduced by 1M*(5M/20M)=1/4M, and the secondary token bucket G is reduced by 1M*(15M/20M)=3/4M. This ensures that when the high-priority packet type B is forwarded, the low-priority type F and G packets can only occupy the remaining bandwidth, thereby realizing the absolute forwarding of high priority.
(2)单层令牌桶的检测更新(2) Detection update of single-layer token bucket
对于只有一级令牌桶的单层令牌桶,当有匹配类型的报文经过时,直接检测其中的令牌数是否满足报文转发的需要,比如说最高优先级的匹配类型A的报文经过时,对一级令牌桶A进行检测,如果满足要求,就直接转发,否则丢弃掉该报文。For a single-level token bucket with only one level of token buckets, when a packet of a matching type passes by, it is directly checked whether the number of tokens in it meets the needs of packet forwarding, for example, the packet of the highest priority matching type A When the message passes, check the first-level token bucket A, if it meets the requirements, it will be forwarded directly, otherwise, the message will be discarded.
此时类型A的报文的转发上限就是整个令牌桶A的带宽,只要有类型A的报文经过,不论其他类型报文是否占用带宽,都可以直接进行对其转发。At this time, the upper limit of forwarding packets of type A is the bandwidth of the entire token bucket A. As long as packets of type A pass through, regardless of whether other types of packets occupy bandwidth, they can be forwarded directly.
在转发的同时,还要对令牌桶B到H进行更新,更新方法同上述双层令牌桶的更新方式一样。这样就保证了在对类型A的报文进行转发时,较低优先级的其他类型报文只能占用类型A报文不需要的剩余带宽,并按照各自的带宽数进行分配。While forwarding, the token buckets B to H are also updated, and the update method is the same as that of the above-mentioned two-layer token bucket. This ensures that when Type A packets are forwarded, other types of packets with lower priorities can only occupy the remaining bandwidth that Type A packets do not need, and allocate them according to their respective bandwidths.
相应于本发明的方法,本发明还提供一种基于令牌桶的报文转发装置,如图4所示,该装置包括:Corresponding to the method of the present invention, the present invention also provides a message forwarding device based on a token bucket, as shown in Figure 4, the device includes:
令牌桶设置单元101,用于基于优先级设置令牌桶,每个不同优先级令牌桶初始化容量为全部可用带宽;The token
检测转发单元102,用于当接收到某一优先级的报文时,采用与该报文相匹配的令牌桶进行报文转发,如果该令牌桶中的令牌数满足转发该报文的要求,则对该报文进行转发,否则丢弃该报文,同时触发更新单元;The detection and
更新单元103,用于更新该优先级令牌桶以及较低优先级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,所述该优先级令牌桶以及较低优先级令牌桶的当前容量为其更新后的令牌桶容量。The
基于某优先级内的不同报文类型,所述令牌桶设置单元101包括:Based on different message types in a certain priority, the token
单层令牌桶设置模块,用于将某一优先级的令牌桶设置为单层令牌桶,所述单层令牌桶为一级令牌桶,其容量初始化为全部可用带宽;和/或A single-level token bucket setting module, configured to set a certain priority token bucket as a single-level token bucket, the single-level token bucket is a first-level token bucket, and its capacity is initialized to all available bandwidth; and /or
双层令牌桶设置模块,用于将某一优先级的令牌桶设置为双层令牌桶,所述双层令牌桶包括一级令牌桶和分别与该优先级内不同类型报文相匹配的多个二级令牌桶,所述一级令牌桶初始化容量为全部可用带宽,所述多个二级令牌桶容量之和等于所述一级令牌桶的容量。The double-layer token bucket setting module is used to set the token bucket of a certain priority level as a double-layer token bucket, and the double-layer token bucket includes a first-level token bucket and a The initial capacity of the first-level token bucket is all available bandwidth, and the sum of the capacities of the multiple second-level token buckets is equal to the capacity of the first-level token bucket.
当所述令牌桶设置单元将某一优先级的令牌桶设置为双层令牌桶时,所述检测转发单元102包括:When the token bucket setting unit sets a token bucket of a certain priority as a double-layer token bucket, the detection and
第一检测转发模块,用于当所述与该报文相匹配的令牌桶为二级令牌桶时,检测该二级令牌桶中的令牌数是否满足转发该报文的要求,是则对该报文进行转发;否则,进一步检测该优先级一级令牌桶中的令牌数是否满足转发该报文的要求,是则进行报文转发,否则丢弃该报文。The first detection and forwarding module is used to detect whether the number of tokens in the second-level token bucket meets the requirements for forwarding the message when the token bucket matching the message is a second-level token bucket, If yes, the message is forwarded; otherwise, it is further detected whether the number of tokens in the token bucket of the priority level meets the requirements for forwarding the message, and if so, the message is forwarded, otherwise, the message is discarded.
当所述令牌桶设置单元将某一优先级的令牌桶设置为双层令牌桶时,所述更新单元包括:本优先级更新模块,用于在该优先级令牌桶为双层令牌桶时更新该报文相匹配的二级令牌桶和该优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,并将所述该二级令牌桶和该一级令牌桶更新后的令牌桶容量为其当前容量。When the token bucket setting unit sets the token bucket of a certain priority as a double-layer token bucket, the update unit includes: this priority update module, which is used to set the priority token bucket as a double-layer token bucket When updating the token bucket, the capacity of the secondary token bucket matching the message and the priority primary token bucket is its current capacity minus the number of tokens used to forward the message, and the two The first-level token bucket and the updated token bucket capacity of the first-level token bucket are its current capacity.
当所述令牌桶设置单元将某一优先级的令牌桶设置为双层令牌桶时,所述更新单元103包括:When the token bucket setting unit sets a token bucket of a certain priority as a double-layer token bucket, the
低优先级更新模块,用于在较优先级令牌桶为双层令牌桶时更新该较低优先级一级令牌桶的容量为其当前容量减去转发该报文所使用的令牌数,以及更新该较低优先级内每个二级令牌桶的容量为其当前容量减去相应比例的转发该报文所使用的令牌数,其中所述相应比例为每个二级令牌桶与该较低优先级一级令牌桶的容量比,并将所述该较低优先级中二级令牌桶和一级令牌桶更新后的令牌桶容量为其当前容量。A low-priority update module, configured to update the lower-priority first-level token bucket when the higher-priority token bucket is a double-layer token bucket. The capacity of the lower-priority first-level token bucket is its current capacity minus the token used to forward the message number, and update the capacity of each secondary token bucket in the lower priority level to its current capacity minus the corresponding proportion of the number of tokens used to forward the message, wherein the corresponding proportion is the number of tokens used by each secondary order The capacity ratio of the card bucket to the lower priority first-level token bucket, and the updated token bucket capacity of the lower-priority second-level token bucket and the first-level token bucket as its current capacity.
虽然已参照上述典型实施例描述了本发明,但应当理解,所用的术语是说明和示例性、而非限制性的术语。由于本发明能够以多种形式具体实施而不脱离发明的精神或实质,所以应当理解,上述实施例不限于任何前述的细节,而应在随附权利要求所限定的精神和范围内广泛地解释,因此落入权利要求或其等效范围内的全部变化和改型都应为随附权利要求所涵盖。While the invention has been described with reference to the foregoing exemplary embodiments, it is to be understood that the terms which have been used are words of description and illustration, rather than of limitation. Since the present invention can be embodied in many forms without departing from the spirit or essence of the invention, it should be understood that the above-described embodiments are not limited to any of the foregoing details, but should be construed broadly within the spirit and scope of the appended claims. , all changes and modifications falling within the scope of the claims or their equivalents shall be covered by the appended claims.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009101433911A CN101557348B (en) | 2009-05-25 | 2009-05-25 | A message forwarding method and device based on token bucket |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009101433911A CN101557348B (en) | 2009-05-25 | 2009-05-25 | A message forwarding method and device based on token bucket |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101557348A CN101557348A (en) | 2009-10-14 |
CN101557348B true CN101557348B (en) | 2012-03-28 |
Family
ID=41175298
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2009101433911A Expired - Fee Related CN101557348B (en) | 2009-05-25 | 2009-05-25 | A message forwarding method and device based on token bucket |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101557348B (en) |
Families Citing this family (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102148830B (en) | 2011-03-31 | 2014-03-26 | 杭州华三通信技术有限公司 | Method for controlling flow of authentication server and authentication access device |
WO2013000112A1 (en) * | 2011-06-28 | 2013-01-03 | 中兴通讯股份有限公司 | Rate limit method and device for leaky bucket |
WO2013000114A1 (en) * | 2011-06-28 | 2013-01-03 | 中兴通讯股份有限公司 | Rate limit method and device for leaky bucket |
WO2013000113A1 (en) * | 2011-06-28 | 2013-01-03 | 中兴通讯股份有限公司 | Rate limit method and apparatus for leaky bucket |
CN103997467B (en) * | 2014-05-20 | 2017-11-14 | 深圳市共进电子股份有限公司 | A kind of method and device of data flow Stochastic Fair share of bandwidth |
CN104219169B (en) * | 2014-09-30 | 2017-11-10 | 新华三技术有限公司 | Class-based queue CBQ dispatching methods and equipment |
CN104702528B (en) * | 2015-04-09 | 2018-07-10 | 深圳中兴网信科技有限公司 | Flow control methods and flow control system |
CN105991467B (en) * | 2015-04-15 | 2019-05-07 | 杭州迪普科技股份有限公司 | A kind of message forwarding method and device |
CN106302239A (en) * | 2015-05-25 | 2017-01-04 | 深圳市中兴微电子技术有限公司 | A kind of method and device of single multicast flow scheduling management |
CN106330755A (en) * | 2015-06-16 | 2017-01-11 | 中兴通讯股份有限公司 | Message flow regulation method and device and mobile communication gateway |
CN105939285A (en) * | 2015-08-21 | 2016-09-14 | 杭州迪普科技有限公司 | Message forwarding method and device |
CN105764091B (en) * | 2016-02-19 | 2019-02-01 | 杭州敦崇科技股份有限公司 | A method of effective use wireless bandwidth |
CN106603429B (en) * | 2016-12-16 | 2019-12-03 | 无锡路通视信网络股份有限公司 | A kind of ACS system overload guard method based on token bucket |
CN108418766B (en) * | 2018-03-05 | 2021-12-17 | 京信网络系统股份有限公司 | Bandwidth control method, device and system |
CN110943934A (en) * | 2019-11-19 | 2020-03-31 | 上海钧正网络科技有限公司 | Service request processing method, system, terminal and readable storage medium |
CN115080657B (en) * | 2021-03-10 | 2024-09-27 | 中国移动通信集团山东有限公司 | A method, system and device for allocating operation tokens for distributed storage |
CN112953848B (en) * | 2021-03-12 | 2023-05-02 | 西安电子科技大学 | Traffic supervision method, system and equipment based on strict priority |
CN115766592A (en) * | 2022-10-31 | 2023-03-07 | 中科驭数(北京)科技有限公司 | Flow rate limiting method based on priority, DPU message forwarding method and device |
-
2009
- 2009-05-25 CN CN2009101433911A patent/CN101557348B/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
CN101557348A (en) | 2009-10-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101557348B (en) | A message forwarding method and device based on token bucket | |
TWI510030B (en) | System and method for performing packet queuing on a client device using packet service classifications | |
CN107196877B (en) | Network flow control method and network device thereof | |
US11616723B2 (en) | Techniques to reduce network congestion | |
CN102449965B (en) | Relay device | |
CN102223306B (en) | A kind of message transmitting method and device | |
CN108259383A (en) | The transmission method and the network equipment of a kind of data | |
US10063478B2 (en) | Switching device and control method of switching device | |
US11621918B2 (en) | Techniques to manage data transmissions | |
CN102811176B (en) | A kind of data flow control method and device | |
CN102104545A (en) | Credit scheduling method and device and bypass device for solving linear speed of packet | |
CN103428099B (en) | A kind of method of universal multi-core network processor flow control | |
CN103139103A (en) | Control method and device for network congestion | |
US7933283B1 (en) | Shared memory management | |
CN111131061B (en) | Data transmission method and network equipment | |
US20180115498A1 (en) | Systems and methods for adaptive credit-based flow | |
CN101478486B (en) | Method, equipment and system for switch network data scheduling | |
CN102143053B (en) | Method, device and system for transmitting data | |
CN103001893B (en) | Multipath transmitting method and exchange chip | |
CN106789735B (en) | Concurrent processing method based on energy priority of data transmission terminal | |
Liang et al. | Queue‐based congestion detection and multistage rate control in event‐driven wireless sensor networks | |
CN109039934B (en) | Space DTN network congestion control method and system | |
CN108234350A (en) | A kind of dispatching method and customer premises equipment | |
CN104079500B (en) | A kind of array dispatching method and device | |
JP7205530B2 (en) | Transmission device, method and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address | ||
CP03 | Change of name, title or address |
Address after: 310052 Binjiang District Changhe Road, Zhejiang, China, No. 466, No. Patentee after: NEW H3C TECHNOLOGIES Co.,Ltd. Address before: 310053 Hangzhou hi tech Industrial Development Zone, Zhejiang province science and Technology Industrial Park, No. 310 and No. six road, HUAWEI, Hangzhou production base Patentee before: HANGZHOU H3C TECHNOLOGIES Co.,Ltd. |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20120328 |