WO2015161552A1 - Method and device for traffic policing based on token bucket - Google Patents

Method and device for traffic policing based on token bucket Download PDF

Info

Publication number
WO2015161552A1
WO2015161552A1 PCT/CN2014/079984 CN2014079984W WO2015161552A1 WO 2015161552 A1 WO2015161552 A1 WO 2015161552A1 CN 2014079984 W CN2014079984 W CN 2014079984W WO 2015161552 A1 WO2015161552 A1 WO 2015161552A1
Authority
WO
WIPO (PCT)
Prior art keywords
length value
mantissa
packet
value
message
Prior art date
Application number
PCT/CN2014/079984
Other languages
French (fr)
Chinese (zh)
Inventor
王凤彬
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015161552A1 publication Critical patent/WO2015161552A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a token bucket-based traffic policing method and apparatus.
  • BACKGROUND Currently, packet switching devices generally use traffic policing to limit the rate of service flows to implement bandwidth control for each service flow.
  • 1 is a schematic diagram of a typical traffic policing application in the prior art.
  • an FTP (File Transfer Protocol) client PCI 101 passes from a packet switching device A 102 and a packet switching device B 103 from an FTP server.
  • the PC2 104 performs the FTP download application.
  • the packet switching device A 102 is configured with a token bucket-based traffic rate limiting function.
  • the maximum width of the CBS/EBS in the rate limiting parameter area is fixed, that is, the maximum value of the settable range of the token bucket depth is limited.
  • the maximum value of CBS/EBS is still unable to meet the speed limit requirement, there will be a situation where the average download rate of the customer cannot be guaranteed.
  • the rate limit algorithm is implemented by the software algorithm module, the bit width of the CBS/EBS in the rate limit parameter area is variable.
  • the maximum value of the CBS/EBS is still not enough, the CBS/ in the speed limit parameter area can be extended. The bit width of EBS has reached the goal of meeting the speed limit requirement, but the method is at the expense of large storage space.
  • a primary object of embodiments of the present invention is to provide a token bucket-based traffic policing method and apparatus having the same inventive concept, which aims to improve speed limit accuracy.
  • the embodiment of the present invention provides a token bucket-based traffic policing method, where the method includes: Obtaining the length value of the currently received packet and the index of the rate limit parameter; adding the length value of the currently received packet to the mantissa of the length value of the previous received packet, to obtain a new packet length value; The length of the packet, according to the preset calculation rule, obtains the new packet tail number and the actual packet length value that needs to be the current rate limit; the actual packet length value and the speed limit parameter index according to the current required speed limit The speed limit result is obtained, and the current received message is subjected to a rate limiting process according to the speed limit result and the preset speed limit condition, and the new message tail number or the length of the last received message is The mantissa of the value is used as the mantissa of the length value of the currently received message.
  • the step of adding the length value of the currently received packet to the mantissa of the length value of the previous received packet to obtain a new packet length value further includes: obtaining the length of the previous received packet The mantissa of the value.
  • the step of obtaining a new packet tail number and an actual packet length value of the current rate limit according to the preset packet length value according to the preset packet length value further includes: acquiring the token bucket depth The parameter, the token bucket depth parameter includes a mantissa mask value and a message length shift value.
  • the step of obtaining a new packet tail number and an actual packet length value that needs to be rate-limiting according to the preset packet length value according to the new packet length value is specifically: Performing an AND operation on the new packet length value and the mantissa mask value to obtain a new packet mantissa; performing a right shift operation on the new packet length value according to the packet length shift value , Obtain the actual packet length value that needs the current rate limit.
  • the embodiment of the present invention further provides a token bucket-based traffic policing device, where the device includes a receiving module, an acquiring module, a calculating module, a speed limiting module, a decision module, and a sending module.
  • the receiving module is configured to receive an ether.
  • the collection module is further configured to: Obtaining a mantissa of a length value of the received packet; and obtaining a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value.
  • the calculation module is configured to: add the obtained length value of the currently received message to the mantissa of the length value of the previous received message to obtain a new message length value; and the new message Performing an AND operation on the length value and the mantissa mask value to obtain a new message mantissa; and performing a right shift operation on the new message length value according to the message length shift value to obtain a current speed limit The actual message length value.
  • FIG. 1 is a schematic diagram of a typical traffic policing application in the prior art
  • FIG. 2 is a schematic flowchart of a token bucket-based traffic policing method according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a module structure of an embodiment of the token bucket-based traffic policing apparatus of the present invention.
  • FIG. 2 is a schematic flowchart diagram of an embodiment of a token bucket-based traffic policing method according to an embodiment of the present invention.
  • the method for the traffic policing based on the token bucket includes the following steps: Step S01: Obtain the length value of the currently received packet and the index of the rate limit parameter.
  • the Ethernet packet received in the second embodiment It is called the current received message.
  • the current received message refers to the first Ethernet packet.
  • the first Ethernet packet is the current received packet as an example, and the token bucket-based traffic policing method is described in the present invention, that is, the length of the currently received packet obtained in step S01 is the first ether. The length of the network packet.
  • Step S02 Add the length value of the currently received packet to the mantissa of the length value of the previous received packet, and obtain a new packet length value. Specifically, in this embodiment, the current received packet is obtained. After the length value of Current Length (100), the length value of the current received message, Current Length (100), plus the length of the previous received message.
  • Step S03 According to the new packet length value, according to the preset calculation rule, obtain a new packet tail number and an actual packet length value that needs to be rate-limiting. Specifically, the new packet length value obtained in step S02 is Update.
  • the new message mantissa Update TailVal is equal to the result of the AND operation of the new message length value Update Length ("110 0100") and the mantissa mask value Tail Mask ("1111"), that is, "110"0100” and “1111” perform the AND operation, and the decimal result corresponding to the operation result "OlOO'V'OlOO" is 4, that is, the new message mantissa Update TailVal is 4. Since the message length shift value Shift RightVal is 4, in this embodiment, the actual packet length value of the current rate limit is only equal to the new packet length value Update Length ("110 0100") 4 bits shifted right. The actual packet length value of the current rate limit is "110", and the corresponding decimal value is 6.
  • Step S04 Obtain a speed limit result according to the current packet length value and the speed limit parameter index of the current rate limit. Specifically, the embodiment obtains a new packet tail number Update TailVal (4) in step S03. After the actual packet length value (Policing Length) of the current rate limit is selected, the rate limit algorithm is selected according to the speed limit parameter in the speed limit parameter index (Policing Index (0) obtained in step S01, and the current speed limit is required. The packet length value (Policing Length) is processed by the rate limit to obtain the speed limit result.
  • Step S05 Perform rate limiting processing on the currently received packet according to the rate limiting result and the preset rate limiting condition, and set the mantissa of the new packet or the mantissa of the length value of the last received packet.
  • the mantissa of the length value of the currently received message Specifically, when the step S04 or the obtained rate limit result meets the preset speed limit condition, the current received message is forwarded, and the new message tail number Update TailVal (4) obtained in step S03 is used as the current receiving report. When the speed limit result obtained in step S04 does not meet the preset speed limit condition, the current received message is discarded, and the mantissa of the length value of the previous received message is Prior TailVal (0).
  • the difference between the subsequent traffic policing process of the other received packets and the traffic policing process of the first Ethernet packet in this embodiment is also the previous received packet read from the specific address space A.
  • the length of the length value is different, and the other processing steps are the same.
  • the value range of the mantissa of the length value of the received message is related to the configured mantissa mask value Tail Mask and the message length shift value Shift RightVal, for example, if the mantissa mask
  • the value Tail Mask is 5 bits (the message length shift value Shift RightVal is 5), and the mantissa of the length value of the received message has a value range of 0-31.
  • the mantissa mask value Tail Mask (Oxf) occupies 4 bits
  • the mantissa of the length value of the received message has a value range of 0-15.
  • the mantissa of the length value of the received message is accumulated.
  • the rate limit result obtained in step S04 does not meet the preset rate limit condition, when the current received message needs to be discarded, the entire packet is discarded. Therefore, in the case of discarding the packet, the mantissa of the length value of the currently received packet should not be accumulated, but remain unchanged.
  • the mantissa of the length value of the last received packet is used as the length of the currently received packet.
  • the length value of the received message is also 100 bytes
  • the mantissa mask value Tail Mask is 0xf
  • the message length shift value Shift Right is 4,
  • the problem is that the update TailVal is 4 as an example to illustrate the problem of speed limit accuracy: since the message tail number Update TailVal is 4, the tail number of the message should be a token that consumes 4 bytes, so when the tail number of the message is not When processing, a packet of 100 bytes is sent, which actually consumes a 96-byte token, so that the actual traffic is greater than the rate limit traffic.
  • the token bucket-based traffic policing method in this embodiment first obtains the length value of the currently received packet and the index of the rate limit parameter, and adds the length value of the currently received packet to the length of the previous received packet. The mantissa of the value is obtained, and the new packet length value is obtained.
  • the new packet tail number and the actual packet length value currently required to be rate-limited are obtained according to the preset calculation rule;
  • the actual packet length value of the current rate limit and the previously obtained rate limit parameter index are obtained, and the rate limit result is obtained.
  • the obtained rate limit result meets the preset rate limit condition, the current received packet is forwarded, and
  • the new packet tail number is used as the mantissa of the length value of the current received packet.
  • the rate limit result does not meet the preset rate limit condition
  • the current received packet is discarded, and the length of the previous received packet is
  • the mantissa is used as the mantissa of the length value of the currently received message.
  • the invention improves the speed limit accuracy.
  • Step S011 Acquire a mantissa of a length value of a previous received packet; specifically, the implementation For example, the mantissa Prior Tail Val of the length value of the previous received message is read from the specific storage space A.
  • the value of the mantissa of the length value of the previous received message is 0.
  • the embodiment further includes: Step S021: Obtain a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value; specifically, the embodiment is The token bucket depth parameter is read from a specific storage space B, where the token bucket depth parameter includes a mantissa mask value Tail Mask and a message length shift value Shift Right.
  • the configuration value of the mantissa mask value Tail Mask is 0xf
  • the configuration value of the message length shift value Shift Right is 4, and therefore, the mantissa mask value Tail Mask obtained in step S021 of this embodiment is 0xf, the obtained message length shift value Shift Right is 4.
  • the token bucket-based traffic policing method in this embodiment first obtains the current received packet length value, the rate limit parameter index, the mantissa of the length of the previous received packet, and the token bucket depth parameter (including the mantissa mask).
  • the code value and the message length shift value the length value of the received current received message is added to the mantissa of the length value of the previous received message to obtain a new message length value; and then the new report is obtained.
  • the text length value and the mantissa mask value are ANDed to obtain a new message mantissa, and according to the message length shift value, the obtained new message length value is right-shifted to obtain the current actual speed limit report.
  • the length of the text then, according to the actual speed limit of the current required speed limit The speed value and the previously obtained speed limit parameter index are obtained, and the speed limit result is obtained. Finally, when the obtained speed limit result satisfies the preset speed limit condition, the current received message is forwarded, and the new message tail is used as the current If the rate limit result does not meet the preset rate limit condition, the current received packet is discarded, and the mantissa of the length of the previous received packet is used as the length of the current received packet. The mantissa of the value.
  • the invention improves the speed limit accuracy.
  • the present invention also provides a token bucket-based traffic policing device. FIG.
  • the token bucket-based traffic policing 200 in this embodiment includes a receiving module 201, an acquiring module 202, a calculating module 203, a rate limiting module 204, a decision module 205, and a sending module 206, where: the receiving module 201, Specifically, in the embodiment of the present invention, the Ethernet packet received by the receiving module 201 is referred to as the currently received packet, and the current received packet received by the receiving module 201 in the initial state. Refers to the first Ethernet packet.
  • the storage module 2021 is configured to store a mantissa of a length value of the previous received message and a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value Tail Mask and a message length shift value Shift Right.
  • the collecting module 202 is configured to obtain the length value of the currently received packet and the index of the rate limit parameter. Specifically, in this embodiment, after the receiving module 201 receives the currently received packet, the collecting module 202 obtains the length of the currently received packet. The value Current Length and the speed limit parameter index Policy Index.
  • the speed limit parameter indexing includes a committed information rate CIR, an excess information rate EIR, a committed burst length CBS, an excess burst length EBS, a color sensitive mode, and a rate limiting algorithm.
  • the configuration value of the current length of the received packet is 100 bytes
  • the configuration value of the speed limit parameter indexing index is 0, that is, the current receiving report obtained by the collecting module 202 in this embodiment is obtained.
  • the length value of the text is 100 and the index of the speed limit parameter is 0.
  • the collection module 202 is further configured to obtain the prologue of the length of the previous received packet, the Prior TailVal, and the depth parameter of the token bucket, and the token bucket depth parameter includes the tail mask value Tail Mask and the packet.
  • the length shift value Shift Right is the length shift value Shift Right.
  • the acquisition module 202 reads the mantissa Prior TailVal of the length value of the previous received message from the specific storage space A of the storage module 2021, and reads the token bucket depth parameter from the specific storage space B of the storage module 2021.
  • the mantissa mask value Tail Mask and the message length shift value Shift Right) in this embodiment, the previous one
  • the mantissa of the length value of the received message has a value of 0, the Tail Mask of the mantissa is Oxf (hexadecimal), and the length of the message length Shift Right is 4.
  • the storage module 2021 is disposed in the collection module 202.
  • the calculation module 203 is configured to add the obtained length value of the currently received packet to the mantissa of the length value of the previous received packet to obtain a new packet length value; and according to the new packet length value, according to the new packet length value
  • the preset calculation rule is used to obtain the new packet tail number and the actual packet length value that needs to be limited. Specifically, after the acquisition module 202 obtains the length value Current of the currently received message, the calculation module 203 is configured to add the length value (Current Length (100) of the received current received message to the previous received message.
  • the new packet mantissa Update TailVal is equal to the new packet length value Update Length ( 100) and the result of the operation of the mantissa mask value Tail Mask (Oxf), the new message mantissa Update TailVal is equal to 4.
  • the actual packet length value of the current rate limit is equal to the new packet length value.
  • the update length of the message length is 0. (100) Move 4 bits to the right to get the actual packet length value of the current rate limit.
  • the Policy Length is equal to 6.
  • the speed limit module 204 is configured to obtain a speed limit result according to the actual message length value and the speed limit parameter index of the current required speed limit.
  • the decision module 205 uses the new message tail number Update Tail Val (4) as the mantissa of the length value of the currently received message;
  • the decision module 205 takes the mantissa Prior TailVal (0) of the length value of the previous received message as the mantissa of the length value of the currently received message.
  • the sending module 206 is configured to forward or discard the currently received packet according to the speed limit result and the preset speed limit condition.
  • the sending module 206 forwards the currently received message; the speed limit result obtained by the rate limiting module 204 is not satisfied.
  • the sending module 206 discards the currently received message.
  • the receiving module receives the Ethernet packet; the storage module stores the mantissa of the length of the received packet and the token bucket depth parameter (including the mantissa mask value and the report). The length of the text is shifted by the acquisition module. The acquisition module obtains the length value of the current received packet and the index of the speed limit parameter.
  • the calculation module sets the length of the currently received packet to the mantissa of the length of the received packet.
  • the new packet length value is obtained, and the calculation module is further configured to obtain a new packet tail number and an actual packet length value that needs to be rate-limiting according to the new packet length value according to the new packet length value;
  • the actual packet length value and the rate limit parameter index of the current rate limit are obtained, and the speed limit result is obtained.
  • the decision module uses the new packet tail number or the mantissa of the length value of the previous received packet as the current received packet according to the speed limit result.
  • the mantissa of the length value; the sending module forwards or discards the currently received packet according to the rate limit result.
  • the present invention improves the speed limit accuracy relative to the prior art.
  • the above description is only the preferred embodiment of the present invention, and is not intended to limit the scope of the invention, and the equivalent structure or equivalent flow transformation made by the specification and the drawings of the present invention may be directly or indirectly applied to other related
  • the technical field is equally included in the scope of patent protection of the present invention.
  • Industrial Applicability The embodiment of the present invention provides the foregoing technical solution, which may be applied to the process of the traffic policing based on the token bucket, obtaining the length value of the currently received packet and the index of the rate limit parameter, and acquiring the currently received packet.
  • the length value is added to the mantissa of the length value of the previous received packet to obtain a new packet length value.
  • the new packet tail number and the current limit are obtained according to the preset calculation rule.
  • the actual value of the actual packet length is obtained.
  • the speed limit result is obtained according to the actual packet length value of the current rate limit and the previously obtained speed limit parameter index.
  • Receive packets for speed limiting, and new The mantissa of the message or the mantissa of the length value of the last received message is used as the mantissa of the length value of the currently received message, which effectively increases the speed limit accuracy.

Landscapes

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

Abstract

Disclosed in the present invention are a method and device for traffic policing based on a token bucket, and the method includes: acquiring a length value of a currently received message and a rate-limiting parameter index; obtaining a new message length value by adding the length value mantissa of a previously received message to the length value of the currently received message; according to a preset computation rule and on the basis of the new message length value, acquiring a new message mantissa and the actual length value of the current message for which rate-limiting is required; acquiring a rate-limiting result according to the actual length value of the current message for which rate-limiting is required and the corresponding rate-limiting parameters in the rate-limiting parameter index; performing rate-limiting processing on the currently received message according to the rate-limiting result and a preset rate-limiting condition, and taking the new message mantissa or the length value mantissa of the previously received message as the length value mantissa of the currently received message. By the present invention, rate-limiting precision can be improved.

Description

基于令牌桶的流量监管方法及装置 技术领域 本发明涉及通讯技术领域, 尤其涉及一种基于令牌桶的流量监管方法及装置。 背景技术 目前, 分组交换设备通常采用流量监管 (Policing)对业务流的速率进行限制, 以 实现对每个业务流的带宽控制。 图 1是现有技术中典型的流量监管的应用示意图, 如 图 1所示, FTP (File Transfer Protocol, 文件传输协议)客户端 PCI 101通过分组交换 设备 A 102和分组交换设备 B 103从 FTP服务器 PC2 104 进行 FTP下载的应用, 分 组交换设备 A 102配置了基于令牌桶的流量限速功能, 如果分组交换设备 A 102中的 流量监管功能所能够配置的承诺突发长度 (Committed Burst Size, 简称为 CBS) 或超 额突发长度 (Excess Burst Size, 简称为 EBS) 不是足够大 (即令牌桶桶深的可设置范 围的最大值过小), 则不能保证客户的平均下载速率。 现有技术中基于令牌桶的流量监管方法通常包括以下两种: (一)流量限速算法由 硬件微引擎实现; (二)流量限速算法由软件算法模块实现。 然而, 当流量限速算法由 硬件微引擎实现时, 由于限速参数区中 CBS/EBS的位宽固定, 从而限定了最大值(即 限定了令牌桶桶深的可设置范围的最大值), 当 CBS/EBS取最大值仍然无法满足限速 需求时, 就会出现不能保证客户的平均下载速率的情况。 而当流量限速算法由软件算 法模块实现时, 限速参数区中 CBS/EBS的位宽可变, 当 CBS/EBS取最大值仍然无法 满足需求时, 可以通过扩展限速参数区中 CBS/EBS 的位宽已达到满足限速需求的目 的, 但是该方法是以牺牲较大存储空间为代价的, 当存储空间不够时, 则难以扩展限 速参数区中 CBS/EBS的位宽 (即难以扩展令牌桶桶深)。 而常用的按比例控制令牌发 放速度和令牌领取速度的扩展 CBS/EBS方法,虽然可以解决上述方法(一)和方法(二) 的不足之处, 但是该方法的限速精度较低。 发明内容 本发明实施例的主要目的是提供一种具有相同发明构思的基于令牌桶的流量监管 方法和装置, 旨在提高限速精度。 为了达到上述目的, 本发明实施例提出一种基于令牌桶的流量监管方法, 该方法 包括: 获取当前接收报文的长度值和限速参数索引; 将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新 的报文长度值; 根据所述新的报文长度值, 按照预置计算规则, 获得新的报文尾数以及当前需要 限速的实际报文长度值; 根据所述当前需要限速的实际报文长度值及所述限速参数索引, 获得限速结果; 根据所述限速结果及预置限速条件, 对所述当前接收报文进行限速处理, 并将所 述新的报文尾数或所述上一次接收报文的长度值的尾数作为当前接收报文的长度值的 尾数。 优选地, 所述根据所述限速结果及预置限速条件, 对所述当前接收报文进行限速 处理, 并将所述新的报文尾数或所述上一次接收报文的长度值的尾数作为当前接收报 文的长度值的尾数的步骤具体为: 当所述限速结果满足预置限速条件时, 将所述当前接收报文进行转发处理, 并将 所述新的报文尾数作为当前接收报文的长度值的尾数; 当所述限速结果不满足预置限速条件时, 将所述当前接收报文进行丢弃处理, 并 将所述前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数。 优选地, 所述将获取到的当前接收报文的长度值加上前一个接收报文的长度值的 尾数, 得到新的报文长度值的步骤之前还包括: 获取前一个接收报文的长度值的尾数。 优选地, 所述根据所述新的报文长度值, 按照预置计算规则, 获得新的报文尾数 以及当前需要限速的实际报文长度值的步骤之前还包括: 获取令牌桶桶深参数, 所述令牌桶桶深参数包括尾数掩码值和报文长度移位值。 优选地, 所述根据所述新的报文长度值, 按照预置计算规则, 获得新的报文尾数 以及当前需要限速的实际报文长度值的步骤具体为: 将所述新的报文长度值和所述尾数掩码值做与运算, 获得新的报文尾数; 按照所 述报文长度移位值, 对所述新的报文长度值做右移运算, 获得当前需要限速的实际报 文长度值。 本发明实施例还提出一种基于令牌桶的流量监管装置, 该装置包括接收模块、 采 集模块、 计算模块、 限速模块、 决策模块及发送模块; 其中, 所述接收模块, 设置为接收以太网报文; 所述采集模块, 设置为获取当前接收报文的长度值和限速参数索引; 所述计算模块, 设置为将获取到的当前接收报文的长度值加上前一个接收报文的 长度值的尾数, 得到新的报文长度值; 以及根据所述新的报文长度值, 按照预置计算 规则, 获得新的报文尾数以及当前需要限速的实际报文长度值; 限速模块,设置为根据所述当前需要限速的实际报文长度值及所述限速参数索引, 获得限速结果; 所述决策模块, 设置为根据所述限速结果及预置限速条件, 将所述新的报文尾数 或所述前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数; 所述发送模块, 设置为根据所述限速结果及预置限速条件, 对所述当前接收报文 进行转发或丢弃处理。 优选地, 所述决策模块设置为: 当所述限速结果满足预置限速条件时, 将所述新的报文尾数作为当前接收报文的 长度值的尾数; 当所述限速结果不满足预置限速条件时, 将所述前一个接收报文的长度值的尾数 作为当前接收报文的长度值的尾数。 优选地, 所述发送模块设置为: 当所述限速结果满足预置限速条件时, 将所述当前接收报文进行转发处理; 当所述限速结果不满足预置限速条件时, 将所述当前接收报文进行丢弃处理。 优选地, 所述采集模块还设置为: 获取前一个接收报文的长度值的尾数; 以及获取令牌桶桶深参数, 所述令牌桶桶 深参数包括尾数掩码值和报文长度移位值。 优选地, 所述计算模块设置为: 将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新 的报文长度值; 以及将所述新的报文长度值和所述尾数掩码值做与运算, 获得新的报 文尾数; 并按照所述报文长度移位值, 对所述新的报文长度值做右移运算, 获得当前 需要限速的实际报文长度值。 本发明实施例提出的基于令牌桶的流量监管方法, 首先获取当前接收报文的长度 值和限速参数索引, 并将获取到的当前接收报文的长度值加上前一个接收报文的长度 值的尾数, 得到新的报文长度值; 然后根据得到的新的报文长度值, 按照预置计算规 贝 U, 获得新的报文尾数以及当前需要限速的实际报文长度值; 接着, 根据当前需要限 速的实际报文长度值及之前获取的限速参数索引, 获得限速结果; 最后, 根据限速结 果及预置限速条件, 对当前接收报文进行限速处理, 并将新的报文尾数或上一次接收 报文的长度值的尾数作为当前接收报文的长度值的尾数。 本发明提高了限速精度。 附图说明 图 1是现有技术中典型的流量监管的应用示意图; 图 2是本发明基于令牌桶的流量监管方法一实施例的流程示意图; 图 3是本发明基于令牌桶的流量监管方法另一实施例的流程示意图; 以及 图 4是本发明基于令牌桶的流量监管装置一实施例的模块结构原理图。 本发明目的的实现、 功能特点及优点将结合实施例, 参照附图做进一步说明。 具体实施方式 以下结合说明书附图及具体实施例进一步说明本发明的技术方案。 应当理解, 此 处所描述的具体实施例仅仅用以解释本发明, 并不用于限定本发明。 本发明提出一种基于令牌桶的流量监管方法。 参照图 2, 图 2是本发明基于令牌桶的流量监管方法一实施例的流程示意图。 本发明基于令牌桶的流量监管方法包括以下步骤: 步骤 S01 : 获取当前接收报文的长度值和限速参数索引; 具体地, 本发明实施例中, 当次所接收到的以太网报文称为当前接收报文, 初始 状态时, 当前接收报文指的是第 1个以太网报文。 本实施例以第 1个以太网报文为当 前接收报文为例, 对本发明基于令牌桶的流量监管方法进行描述, 即步骤 S01获取到 的当前接收报文的长度值就是第 1个以太网报文的长度值。在启用流量监管的情况下, 当前接收报文 (第 1个以太网报文) 携带了报文长度值 Current Length和限速参数索 弓 I Policing Index, 其中限速参数索弓 I Policing Index 包括承诺信息速率 Committed Information Rate, 简称为 CIR)、 超额信息速率 (Excess Burst Rate, 简称为 EIR)、 承 诺突发长度 CBS、 超额突发长度 EBS、 颜色敏感模式、 限速算法等。 本实施例中, 当前接收报文的长度值 Current Length的配置值为 100字节, 限速 参数索引 Policing Index的配置值为 0。 即本实施例中, 步骤 S01所获取到的当前接收 报文的长度值 Current Length为 100, 获取到的限速参数索引 Policing Index为 0。 本实施例中,限速参数索引 Policing Index(承诺信息速率 CIR、超额信息速率 EIR、 承诺突发长度 CBS、 超额突发长度 EBS、 颜色敏感模式、 限速算法) 的配置是由分组 交换网设备中的主板控制平面配置的, 并且, 该主板控制平面还对令牌桶桶深参数进 行配置, 本实施例中, 令牌桶桶深参数包括尾数掩码值 Tail Mask和报文长度移位值 Shift Right, 即主板控制平面对尾数掩码值 Tail Mask和报文长度移位值 Shift Right进 行配置,并根据配置的尾数掩码值 Tail Mask和报文长度移位值 Shift Right更新限速参 数索引中的承诺信息速率 CIR和超额信息速率 EIR。本实施例中,尾数掩码值 Tail Mask 的配置值为 Oxf (十六进制), 对应的二进制为 " 1111 " (即尾数掩码值 Tail Mask占用 4个比特位),本实施例中,报文长度移位值 Shift Right的配置值与尾数掩码值 Tail Mask 所占用的比特位相对应,由于本实施例中尾数掩码值 Tail Mask占用 4个比特位,因此, 报文长度移位值 Shift Right的配置值为 4, 则限速参数索引中更新后的承诺信息速率 CIR'为 CIR/2 (即更新后的承诺信息速率 CIR'为更新前的承诺信息速率 CIR除以 2 的 4次方), 更新后的超额信息速率 EIR'为 EIR/2 (即更新后的超额信息速率 EIR' 为更新前的超额信息速率 EIR除以 2的 4次方)。 步骤 S02: 将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾 数, 得到新的报文长度值; 具体地, 本实施例中, 在获取到当前接收报文的长度值 Current Length ( 100)后, 将获取到的当前接收报文的长度值 Current Length ( 100) 加上前一个接收报文的长度 值的尾数 Prior TailVal (本实施例中, 前一个接收报文的长度值的尾数 Prior TailVal为 0), 得到一个新的报文长度值 Update Length, 即本实施例所得到的新的报文长度值 Update Length =100+0=100。 步骤 S03 : 根据新的报文长度值, 按照预置计算规则, 获得新的报文尾数以及当 前需要限速的实际报文长度值; 具体地,将步骤 S02得到的新的报文长度值 Update Length和尾数掩码值 Tail Mask 做与运算, 得到新的报文尾数 Update TailVal; 并且, 按照报文长度移位值 Shift Right, 对步骤 S02得到的新的报文长度值 Update Length做右移运算,获得当前需要限速的实 际报文长度值 Policing Length。 本实施例中,由于步骤 S02得到的新的报文长度值 Update Length为 100(十进制), 对应的二进制为 " 110 0100 "而尾数掩码值 Tail Mask的配置值为 Oxf (十六进制), 对 应的二进制为 " 1111 ", 报文长度移位值 Shift Right的配置值为 4。 因此, 本实施例中, 新的报文尾数 Update TailVal等于新的报文长度值 Update Length (" 110 0100")和尾数 掩码值 Tail Mask (" 1111 ") 的与运算结果, 即对 " 110 0100"和 " 1111 "进行与运算, 得到运算结果为" OlOO'V'OlOO"对应的十进制为 4,即得到新的报文尾数 Update TailVal 为 4。 由于报文长度移位值 Shift RightVal为 4, 因此, 本实施例中, 当前需要限速的 实际报文长度值 Policing Length等于新的报文长度值 Update Length (" 110 0100") 右 移 4比特, 得到当前需要限速的实际报文长度值 Policing Length为 " 110", 对应的十 进制为 6。 步骤 S04: 根据所述当前需要限速的实际报文长度值及所述限速参数索引, 获得 限速结果; 具体地, 本实施例在步骤 S03获得新的报文尾数 Update TailVal (4) 以及当前需 要限速的实际报文长度值 Policing Length ( 6)之后, 根据步骤 S01中获取的限速参数 索引 Policing Index ( 0) 中对应的限速参数选择限速算法, 对当前需要限速的实际报 文长度值 Policing Length ( 6) 进行限速处理, 获得限速结果。 步骤 S05 : 根据所述限速结果及预置限速条件, 对所述当前接收报文进行限速处 理, 并将所述新的报文尾数或所述上一次接收报文的长度值的尾数作为当前接收报文 的长度值的尾数。 具体地, 当步骤 S04或获取的限速结果满足预置限速条件时, 将当前接收报文进 行转发处理, 并将步骤 S03所获取的新的报文尾数 Update TailVal (4) 作为当前接收 报文的长度值的尾数; 当步骤 S04获取的限速结果不满足预置限速条件时, 将当前接收报文进行丢弃处 理, 并将前一个接收报文的长度值的尾数 Prior TailVal (0) 作为当前接收报文的长度 值的尾数。 当前接收报文的流量监管流程结束。 本实施例中, 第二个接收报文的流量监管处理步骤与上述第 1个以太网报文 (即 第一个接收报文)的流量监管处理步骤的差别是从特定地址空间 A所读取的前一个接 收报文的长度值的尾数不再是 0, 而是上述实施例所得到的新的报文尾数 Update TailVal (4), 第二个接收报文的流量监管处理步骤的其它处理步骤同于上述实施例上 述第 1个以太网报文的处理步骤。 同理, 后续的其他接收报文的流量监管处理步骤与 本实施例上述第 1个以太网报文的流量监管处理步骤的差别也是从特定地址空间 A中 所读取到的前一个接收报文的长度值的尾数不同, 其它的处理步骤都相同。 另外, 需 要说明的是, 本实施例中, 接收报文的长度值的尾数的取值范围与配置的尾数掩码值 Tail Mask和报文长度移位值 Shift RightVal相关, 例如, 若尾数掩码值 Tail Mask是 5 比特(报文长度移位值 Shift RightVal为 5 ),则接收报文的长度值的尾数的取值范围是 0-31。 本实例中, 由于尾数掩码值 Tail Mask (Oxf) 占用 4比特, 因此本实施例中, 接 收报文的长度值的尾数的取值范围就是 0-15。 本实施例中, 接收报文的长度值的尾数是累加的, 当步骤 S04所获取的限速结果 不满足预置限速条件, 当前接收报文需要丢弃处理时, 丢弃的是整个报文, 因此, 在 丢弃报文的情况下, 当前接收报文的长度值的尾数不应该再累加, 而是保持不变, 即 将上一次接收报文的长度值的尾数作为当前接收报文的长度值的尾数, 否则, 后续得 到的当前需要限速的实际报文长度值就会不准确, 导致限速精度降低的问题。 为了便 于理解和说明本发明的限速精度问题, 下面同样以接收报文的长度值 Current Length 为 100字节, 尾数掩码值 Tail Mask为 0xf, 报文长度移位值 Shift Right为 4, 报文尾 数 Update TailVal为 4为例来对限速精度的问题进行说明:由于报文尾数 Update TailVal 为 4, 该报文尾数应该是需要消耗 4字节的令牌, 因此当不对该报文尾数进行处理时, 发送 100字节的报文,其实际消耗了 96字节的令牌,从而出现实际流量大于限速流量 的情况; 当限速结果不满足预置限速条件时, 将报文进行丢弃处理时, 该报文尾数是 不能消耗令牌的, 如果继续将该报文尾数保存写回给下一个报文使用, 将会出现实际 流量小于限速流量的情况。本发明能够有效解决上述两种情况,从而提高了限速精度。 本实施例提出的基于令牌桶的流量监管方法, 首先获取当前接收报文的长度值和 限速参数索引, 并将获取到的当前接收报文的长度值加上前一个接收报文的长度值的 尾数, 得到新的报文长度值; 然后根据得到的新的报文长度值, 按照预置计算规则, 获得新的报文尾数以及当前需要限速的实际报文长度值; 接着, 根据当前需要限速的 实际报文长度值及之前获取的限速参数索引, 获得限速结果; 最后, 当获得的限速结 果满足预置限速条件时, 将当前接收报文进行转发处理, 并将新的报文尾数作为当前 接收报文的长度值的尾数; 当限速结果不满足预置限速条件时, 将当前接收报文进行 丢弃处理, 并将前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数。 本发明提高了限速精度。 图 3是本发明基于令牌桶的流量监管方法另一实施例的流程示意图。 参照图 3, 本实施例基于令牌桶的流量监管方法在图 2的基础上, 在步骤 S02之 前, 还包括: 步骤 S011 : 获取前一个接收报文的长度值的尾数; 具体地, 本实施例是从特定的存储空间 A中读取前一个接收报文的长度值的尾数 Prior Tail Val, 本实施例中, 前一个接收报文的长度值的尾数的值为 0。 进一步地, 本实施例在步骤 S03之前还包括: 步骤 S021 : 获取令牌桶桶深参数, 令牌桶桶深参数包括尾数掩码值和报文长度移 位值; 具体地, 本实施例是从特定的存储空间 B中读取令牌桶桶深参数, 其中令牌桶桶 深参数包括尾数掩码值 Tail Mask和报文长度移位值 Shift Right。 本实施例中, 由于尾 数掩码值 Tail Mask的配置值为 0xf, 报文长度移位值 Shift Right的配置值为 4, 因此, 本实施例步骤 S021所获取到的尾数掩码值 Tail Mask为 0xf, 所获取到的报文长度移 位值 Shift Right为 4。 本实施例提出的基于令牌桶的流量监管方法, 首先获取当前接收报文的长度值、 限速参数索引、 前一个接收报文的长度值的尾数以及令牌桶桶深参数 (包括尾数掩码 值和报文长度移位值),将获取到的当前接收报文的长度值加上前一个接收报文的长度 值的尾数, 得到新的报文长度值; 然后将得到的新的报文长度值和尾数掩码值做与运 算, 获得新的报文尾数, 以及按照报文长度移位值, 对得到的新的报文长度值做右移 运算, 获得当前需要限速的实际报文长度值; 接着, 根据当前需要限速的实际报文长 度值及之前获取的限速参数索引, 获得限速结果; 最后, 当获得的限速结果满足预置 限速条件时, 将当前接收报文进行转发处理, 并将新的报文尾数作为当前接收报文的 长度值的尾数; 当限速结果不满足预置限速条件时, 将当前接收报文进行丢弃处理, 并将前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数。 本发明提高 了限速精度。 本发明还提出一种基于令牌桶的流量监管装置, 图 4是本发明基于令牌桶的流量 监管装置一实施例的模块结构原理图。 参照图 4,本实施例中的基于令牌桶的流量监管 200包括接收模块 201、采集模块 202、 计算模块 203、 限速模块 204、 决策模块 205及发送模块 206, 其中: 接收模块 201, 设置为接收以太网报文; 具体地, 本发明实施例中, 接收模块 201当次所接收到的以太网报文称为当前接 收报文,初始状态时,接收模块 201接收到的当前接收报文指的是第 1个以太网报文。 存储模块 2021, 设置为存储前一个接收报文的长度值的尾数以及令牌桶桶深参 数, 其中令牌桶桶深参数包括尾数掩码值 Tail Mask和报文长度移位值 Shift Right。 采集模块 202, 设置为获取当前接收报文的长度值和限速参数索引; 具体地, 本实施例中, 在接收模块 201接收到当前接收报文后, 采集模块 202获 取当前接收报文的长度值 Current Length和限速参数索引 Policing Index。 其中限速参 数索引 Policing Index包括承诺信息速率 CIR、超额信息速率 EIR、承诺突发长度 CBS、 超额突发长度 EBS、 颜色敏感模式、 限速算法等。 本实施例中, 当前接收报文的长度 值 Current Length的配置值为 100字节, 限速参数索引 Policing Index的配置值为 0, 即本实施例中,采集模块 202所获取到得当前接收报文的长度值 Current Length为 100, 限速参数索引为 0。 本实施例中, 采集模块 202 还设置为获取前一个接收报文的长度值的尾数 Prior TailVal, 以及获取令牌桶桶深参数, 令牌桶桶深参数包括尾数掩码值 Tail Mask和报文 长度移位值 Shift Right。 具体地, 采集模块 202从存储模块 2021的特定存储空间 A中读取前一个接收报 文的长度值的尾数 Prior TailVal, 从存储模块 2021的特定存储空间 B中读取令牌桶桶 深参数 (尾数掩码值 Tail Mask和报文长度移位值 Shift Right), 本实施例中, 前一个 接收报文的长度值的尾数 Prior TailVal为 0,尾数掩码值 Tail Mask为 Oxf (十六进制), 报文长度移位值 Shift Right为 4。 本实施例中, 存储模块 2021设于采集模块 202内。 计算模块 203, 设置为将获取到的当前接收报文的长度值加上前一个接收报文的 长度值的尾数, 得到新的报文长度值; 以及根据所述新的报文长度值, 按照预置计算 规则, 获得新的报文尾数以及当前需要限速的实际报文长度值。 具体地, 当采集模块 202获取到当前接收报文的长度值 Current Length ( 100)后, 计算模块 203设置为将获取到的当前接收报文的长度值 Current Length ( 100) 加上前 一个接收报文的长度值的尾数 Prior TailVal ( 0), 得到一个新的报文长度值 Update Length, 即本实施例所得到的新的报文长度值 Update Length =100+0=100。 并且, 本实 施例中, 计算模块 203还设置为将新的报文长度值 Update Length ( 100+0) 和采集模 块 202所获取到的尾数掩码值 Tail Mask (Oxf) 做与运算, 获得新的报文尾数 Update TailVal;同时,计算模块 203按照采集模块 202所获取到的报文长度移位值 Shift Right, 对新的报文长度值 Update Length做右移运算, 获得当前需要限速的实际报文长度值 Policing Length。 本实施例中, 由于新的报文长度值 Update Length为 100, 尾数掩码 值 Tail Mask为 Oxf, 因此, 本实施例中, 新的报文尾数 Update TailVal等于新的报文 长度值 Update Length ( 100)和尾数掩码值 Tail Mask (Oxf) 的与运算结果, 得到新的 报文尾数 Update TailVal等于 4。 由于报文长度移位值 Shift RightVal为 4, 新的报文长 度值 Update Length为 100,因此本实施例中,当前需要限速的实际报文长度值 Policing Length等于新的报文长度值 Update Length ( 100) 右移 4比特, 得到当前需要限速的 实际报文长度值 Policing Length等于 6。 限速模块 204, 设置为根据所述当前需要限速的实际报文长度值及所述限速参数 索引, 获得限速结果。 具体地, 本实施例在计算模块 203 设置为计算获得新的报文尾数 Update TailVal (4) 以及当前需要限速的实际报文长度值 Policing Length (6) 之后, 限速模块 204 根据采集模块 202所获取的限速参数索引 Policing Index (0) 的限速参数选择限速算 法, 对当前需要限速的实际报文长度值 Policing Length (6) 进行限速处理, 获得限速 结果。 决策模块 205, 设置为根据所述限速结果及预置限速条件, 将新的报文尾数或前 一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数。 具体地, 当限速模块 204获得的限速结果满足预置限速条件时, 决策模块 205将 新的报文尾数 Update Tail Val (4)作为当前接收报文的长度值的尾数; 当限速模块 204 获得的限速结果不满足预置限速条件时, 决策模块 205将前一个接收报文的长度值的 尾数 Prior TailVal (0) 作为当前接收报文的长度值的尾数。 发送模块 206, 设置为根据所述限速结果及预置限速条件, 对当前接收报文进行 转发或丢弃处理。 具体地, 本实施例中, 当限速模块 204得到的限速结果满足预置限速条件时, 发 送模块 206将当前接收报文进行转发处理; 当限速模块 204得到的限速结果不满足预 置限速条件时, 发送模块 206将当前接收报文进行丢弃处理。 本实施例提出的基于令牌桶的流量监管装置, 接收模块接收以太网报文; 存储模 块存储前一个接收报文的长度值的尾数以及令牌桶桶深参数 (包括尾数掩码值和报文 长度移位值); 采集模块获取当前接收报文的长度值和限速参数索引; 计算模块设置为 将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新的报 文长度值, 计算模块还设置为根据新的报文长度值, 按照预置计算规则, 获得新的报 文尾数以及当前需要限速的实际报文长度值; 限速模块根据当前需要限速的实际报文 长度值及限速参数索引, 获得限速结果; 决策模块根据限速结果, 将新的报文尾数或 前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾数; 发送模块根据限 速结果, 对当前接收报文进行转发或丢弃处理。 本发明相对于现有技术提高了限速精 度。 以上所述仅为本发明的优选实施例, 并非因此限制本发明的专利范围, 凡是利用 本发明说明书及附图内容所作的等效结构或等效流程变换, 或直接或间接运用在其他 相关的技术领域, 均同理包括在本发明的专利保护范围内。 工业实用性 本发明实施例提出上述技术方案, 可以应用于基于令牌桶的流量监管的过程中, 获取当前接收报文的长度值和限速参数索引, 并将获取到的当前接收报文的长度值加 上前一个接收报文的长度值的尾数, 得到新的报文长度值; 然后根据得到的新的报文 长度值, 按照预置计算规则,获得新的报文尾数以及当前需要限速的实际报文长度值; 接着, 根据当前需要限速的实际报文长度值及之前获取的限速参数索引, 获得限速结 果; 最后, 根据限速结果及预置限速条件, 对当前接收报文进行限速处理, 并将新的 报文尾数或上一次接收报文的长度值的尾数作为当前接收报文的长度值的尾数, 提有 效的高了限速精度。 The present invention relates to the field of communications technologies, and in particular, to a token bucket-based traffic policing method and apparatus. BACKGROUND Currently, packet switching devices generally use traffic policing to limit the rate of service flows to implement bandwidth control for each service flow. 1 is a schematic diagram of a typical traffic policing application in the prior art. As shown in FIG. 1, an FTP (File Transfer Protocol) client PCI 101 passes from a packet switching device A 102 and a packet switching device B 103 from an FTP server. The PC2 104 performs the FTP download application. The packet switching device A 102 is configured with a token bucket-based traffic rate limiting function. If the traffic policing function in the packet switching device A 102 can be configured with a Committed Burst Size (referred to as a Committed Burst Size). The CBS) or Excess Burst Size (EBS) is not large enough (ie, the maximum value of the token bucket depth is too small), and the average download rate of the customer cannot be guaranteed. The token bucket-based traffic policing method in the prior art generally includes the following two types: (1) The traffic rate limiting algorithm is implemented by a hardware microengine; (2) The traffic rate limiting algorithm is implemented by a software algorithm module. However, when the traffic rate limiting algorithm is implemented by the hardware microengine, the maximum width of the CBS/EBS in the rate limiting parameter area is fixed, that is, the maximum value of the settable range of the token bucket depth is limited. When the maximum value of CBS/EBS is still unable to meet the speed limit requirement, there will be a situation where the average download rate of the customer cannot be guaranteed. When the rate limit algorithm is implemented by the software algorithm module, the bit width of the CBS/EBS in the rate limit parameter area is variable. When the maximum value of the CBS/EBS is still not enough, the CBS/ in the speed limit parameter area can be extended. The bit width of EBS has reached the goal of meeting the speed limit requirement, but the method is at the expense of large storage space. When the storage space is insufficient, it is difficult to expand the bit width of CBS/EBS in the speed limit parameter area (ie, it is difficult Extended token bucket bucket depth). However, the commonly used extended CBS/EBS method for proportionally controlling token issuance speed and token collection speed can solve the shortcomings of the above methods (1) and (2), but the speed limit accuracy of the method is low. SUMMARY OF THE INVENTION A primary object of embodiments of the present invention is to provide a token bucket-based traffic policing method and apparatus having the same inventive concept, which aims to improve speed limit accuracy. To achieve the above objective, the embodiment of the present invention provides a token bucket-based traffic policing method, where the method includes: Obtaining the length value of the currently received packet and the index of the rate limit parameter; adding the length value of the currently received packet to the mantissa of the length value of the previous received packet, to obtain a new packet length value; The length of the packet, according to the preset calculation rule, obtains the new packet tail number and the actual packet length value that needs to be the current rate limit; the actual packet length value and the speed limit parameter index according to the current required speed limit The speed limit result is obtained, and the current received message is subjected to a rate limiting process according to the speed limit result and the preset speed limit condition, and the new message tail number or the length of the last received message is The mantissa of the value is used as the mantissa of the length value of the currently received message. Preferably, the speed limit processing is performed on the current received message according to the speed limit result and the preset speed limit condition, and the new message tail number or the length value of the last received message is The step of the mantissa is the mantissa of the length value of the received packet, and the step of: the current received packet is forwarded and processed, and the new packet is forwarded. The mantissa is used as the mantissa of the length value of the current received message. When the rate limit result does not meet the preset rate limit condition, the current received message is discarded, and the length of the previous received message is used. The mantissa is the mantissa of the length value of the currently received message. Preferably, the step of adding the length value of the currently received packet to the mantissa of the length value of the previous received packet to obtain a new packet length value further includes: obtaining the length of the previous received packet The mantissa of the value. Preferably, the step of obtaining a new packet tail number and an actual packet length value of the current rate limit according to the preset packet length value according to the preset packet length value further includes: acquiring the token bucket depth The parameter, the token bucket depth parameter includes a mantissa mask value and a message length shift value. Preferably, the step of obtaining a new packet tail number and an actual packet length value that needs to be rate-limiting according to the preset packet length value according to the new packet length value is specifically: Performing an AND operation on the new packet length value and the mantissa mask value to obtain a new packet mantissa; performing a right shift operation on the new packet length value according to the packet length shift value , Obtain the actual packet length value that needs the current rate limit. The embodiment of the present invention further provides a token bucket-based traffic policing device, where the device includes a receiving module, an acquiring module, a calculating module, a speed limiting module, a decision module, and a sending module. The receiving module is configured to receive an ether. The network packet is configured to obtain a length value of the currently received packet and a speed limit parameter index. The calculation module is configured to add the length value of the currently received packet to the previous received packet. The mantissa of the length value of the length value is obtained, and the new packet length value is obtained; and according to the new packet length value, the new packet tail number and the actual packet length value currently required to be rate-limited are obtained according to the preset calculation rule; The speed module is configured to obtain a speed limit result according to the actual packet length value and the speed limit parameter index of the current required speed limit; the decision module is set to be based on the speed limit result and the preset speed limit condition And using the new message mantissa or the mantissa of the length value of the previous received message as the mantissa of the length value of the currently received message; The block is configured to forward or discard the currently received packet according to the rate limit result and the preset rate limit condition. Preferably, the decision module is configured to: when the speed limit result meets the preset speed limit condition, the new message tail number is used as the mantissa of the length value of the currently received message; When the preset rate limit condition is met, the mantissa of the length value of the previous received message is used as the mantissa of the length value of the currently received message. Preferably, the sending module is configured to: when the speed limit result meets the preset speed limit condition, forward the current received message; when the speed limit result does not meet the preset speed limit condition, And discarding the currently received packet. Preferably, the collection module is further configured to: Obtaining a mantissa of a length value of the received packet; and obtaining a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value. Preferably, the calculation module is configured to: add the obtained length value of the currently received message to the mantissa of the length value of the previous received message to obtain a new message length value; and the new message Performing an AND operation on the length value and the mantissa mask value to obtain a new message mantissa; and performing a right shift operation on the new message length value according to the message length shift value to obtain a current speed limit The actual message length value. The token bucket-based traffic policing method in the embodiment of the present invention first obtains the current received packet length value and the rate limit parameter index, and adds the obtained current received packet length value to the previous received packet. The mantissa of the length value is obtained, and a new packet length value is obtained. Then, according to the obtained new packet length value, the new packet tail number and the actual packet length value currently required to be the speed limit are obtained according to the preset calculation rule U. Then, the speed limit result is obtained according to the actual packet length value of the current rate limit and the previously obtained speed limit parameter index. Finally, the current rate of the received message is limited according to the speed limit result and the preset speed limit condition. The new message mantissa or the mantissa of the length value of the last received message is used as the mantissa of the length value of the currently received message. The invention improves the speed limit accuracy. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a schematic diagram of a typical traffic policing application in the prior art; FIG. 2 is a schematic flowchart of a token bucket-based traffic policing method according to an embodiment of the present invention; A schematic flowchart of another embodiment of the method; and FIG. 4 is a schematic diagram of a module structure of an embodiment of the token bucket-based traffic policing apparatus of the present invention. The implementation, functional features, and advantages of the present invention will be further described with reference to the accompanying drawings. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The technical solutions of the present invention will be further described below in conjunction with the drawings and specific embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. The invention provides a token bucket based traffic policing method. Referring to FIG. 2, FIG. 2 is a schematic flowchart diagram of an embodiment of a token bucket-based traffic policing method according to an embodiment of the present invention. The method for the traffic policing based on the token bucket includes the following steps: Step S01: Obtain the length value of the currently received packet and the index of the rate limit parameter. Specifically, in the embodiment of the present invention, the Ethernet packet received in the second embodiment It is called the current received message. In the initial state, the current received message refers to the first Ethernet packet. In this embodiment, the first Ethernet packet is the current received packet as an example, and the token bucket-based traffic policing method is described in the present invention, that is, the length of the currently received packet obtained in step S01 is the first ether. The length of the network packet. When traffic policing is enabled, the current received packet (the first Ethernet packet) carries the packet length value Current Length and the speed limit parameter I Policing Index, where the speed limit parameter I Policing Index includes the promise Committed Information Rate (CIR), Excess Burst Rate (EIR), Committed Burst Length CBS, Excess Burst Length EBS, Color Sensitive Mode, Rate Limiting Algorithm, etc. In this embodiment, the configuration value of the current length of the received packet is 100 bytes, and the configuration value of the speed limit parameter index is 0. That is, in this embodiment, the length value of the currently received packet obtained in step S01 is a continuous length of 100, and the obtained speed limit parameter index Policying Index is 0. In this embodiment, the configuration of the rate limit parameter indexing index (committed information rate CIR, excess information rate EIR, committed burst length CBS, excess burst length EBS, color sensitive mode, and rate limiting algorithm) is configured by the packet switching network device. The board control plane is configured, and the board control plane also configures the token bucket depth parameter. In this embodiment, the token bucket depth parameter includes a mantissa mask value Tail Mask and a packet length shift value. Shift Right, that is, the main board control plane configures the mantissa mask value Tail Mask and the message length shift value Shift Right, and updates the speed limit parameter index according to the configured mantissa mask value Tail Mask and the message length shift value Shift Right. Committed information rate CIR and excess information rate EIR. In this embodiment, the configuration value of the mantissa mask value Tail Mask is Oxf (hexadecimal), and the corresponding binary is "1111" (that is, the mantissa mask value Tail Mask occupies 4 bits). In this embodiment, The configuration value of the message length shift value Shift Right corresponds to the bit occupied by the mantissa mask value Tail Mask. Since the mantissa mask value Tail Mask occupies 4 bits in this embodiment, the message length shift value If the configuration value of Shift Right is 4, the updated committed information rate CIR' in the rate limit parameter index is CIR/2 (that is, the updated committed information rate CIR' is the pre-update committed information rate CIR divided by 2 times of 4 times. Party), the updated excess information rate EIR' is EIR/2 (ie, the updated excess information rate EIR' is the pre-update excess information rate EIR divided by 2 to the 4th power). Step S02: Add the length value of the currently received packet to the mantissa of the length value of the previous received packet, and obtain a new packet length value. Specifically, in this embodiment, the current received packet is obtained. After the length value of Current Length (100), the length value of the current received message, Current Length (100), plus the length of the previous received message. The mantissa of the value, the Prior TailVal (in this embodiment, the mantissa of the length of the previous received message, the Prior TailVal is 0), and a new packet length value, Update Length, is obtained, that is, the new packet length obtained in this embodiment. The value Update Length = 100+0=100. Step S03: According to the new packet length value, according to the preset calculation rule, obtain a new packet tail number and an actual packet length value that needs to be rate-limiting. Specifically, the new packet length value obtained in step S02 is Update. The length and the mantissa mask value Tail Mask are ANDed to obtain a new message mantissa Update TailVal; and, according to the message length shift value Shift Right, the new message length value Update Length obtained in step S02 is right-shifted. The actual packet length value of the current rate limit is obtained. In this embodiment, the new packet length value Update Length obtained in step S02 is 100 (decimal), the corresponding binary is "110 0100", and the configuration value of the mantissa mask value Tail Mask is Oxf (hexadecimal). The corresponding binary is "1111", and the configuration value of the message length shift value Shift Right is 4. Therefore, in this embodiment, the new message mantissa Update TailVal is equal to the result of the AND operation of the new message length value Update Length ("110 0100") and the mantissa mask value Tail Mask ("1111"), that is, "110"0100" and "1111" perform the AND operation, and the decimal result corresponding to the operation result "OlOO'V'OlOO" is 4, that is, the new message mantissa Update TailVal is 4. Since the message length shift value Shift RightVal is 4, in this embodiment, the actual packet length value of the current rate limit is only equal to the new packet length value Update Length ("110 0100") 4 bits shifted right. The actual packet length value of the current rate limit is "110", and the corresponding decimal value is 6. Step S04: Obtain a speed limit result according to the current packet length value and the speed limit parameter index of the current rate limit. Specifically, the embodiment obtains a new packet tail number Update TailVal (4) in step S03. After the actual packet length value (Policing Length) of the current rate limit is selected, the rate limit algorithm is selected according to the speed limit parameter in the speed limit parameter index (Policing Index (0) obtained in step S01, and the current speed limit is required. The packet length value (Policing Length) is processed by the rate limit to obtain the speed limit result. Step S05: Perform rate limiting processing on the currently received packet according to the rate limiting result and the preset rate limiting condition, and set the mantissa of the new packet or the mantissa of the length value of the last received packet. The mantissa of the length value of the currently received message. Specifically, when the step S04 or the obtained rate limit result meets the preset speed limit condition, the current received message is forwarded, and the new message tail number Update TailVal (4) obtained in step S03 is used as the current receiving report. When the speed limit result obtained in step S04 does not meet the preset speed limit condition, the current received message is discarded, and the mantissa of the length value of the previous received message is Prior TailVal (0). The mantissa of the length value of the currently received message. The traffic policing process for receiving packets currently ends. In this embodiment, the difference between the traffic policing process of the second received packet and the traffic policing process of the first Ethernet packet (ie, the first received packet) is read from the specific address space A. The mantissa of the length value of the previous received message is no longer 0, but the new packet mantissa Update TailVal (4) obtained in the above embodiment, and other processing steps of the second traffic receiving processing step of receiving the message The processing steps of the first Ethernet packet are the same as those in the above embodiment. Similarly, the difference between the subsequent traffic policing process of the other received packets and the traffic policing process of the first Ethernet packet in this embodiment is also the previous received packet read from the specific address space A. The length of the length value is different, and the other processing steps are the same. In addition, in this embodiment, the value range of the mantissa of the length value of the received message is related to the configured mantissa mask value Tail Mask and the message length shift value Shift RightVal, for example, if the mantissa mask The value Tail Mask is 5 bits (the message length shift value Shift RightVal is 5), and the mantissa of the length value of the received message has a value range of 0-31. In this example, since the mantissa mask value Tail Mask (Oxf) occupies 4 bits, in this embodiment, the mantissa of the length value of the received message has a value range of 0-15. In this embodiment, the mantissa of the length value of the received message is accumulated. When the rate limit result obtained in step S04 does not meet the preset rate limit condition, when the current received message needs to be discarded, the entire packet is discarded. Therefore, in the case of discarding the packet, the mantissa of the length value of the currently received packet should not be accumulated, but remain unchanged. The mantissa of the length value of the last received packet is used as the length of the currently received packet. The mantissa, otherwise, the actual packet length value that is currently required to be rate-limiting will be inaccurate, resulting in a problem of reduced speed limit accuracy. In order to facilitate understanding and explanation of the speed limit accuracy problem of the present invention, the length value of the received message is also 100 bytes, the mantissa mask value Tail Mask is 0xf, and the message length shift value Shift Right is 4, The problem is that the update TailVal is 4 as an example to illustrate the problem of speed limit accuracy: since the message tail number Update TailVal is 4, the tail number of the message should be a token that consumes 4 bytes, so when the tail number of the message is not When processing, a packet of 100 bytes is sent, which actually consumes a 96-byte token, so that the actual traffic is greater than the rate limit traffic. When the rate limit result does not meet the preset rate limit condition, the packet is sent. When the discarding process is performed, the number of digits of the packet cannot be consumed. If the packet is saved and written back to the next packet, the actual traffic will be less than the rate limit traffic. The invention can effectively solve the above two situations, thereby improving the speed limit accuracy. The token bucket-based traffic policing method in this embodiment first obtains the length value of the currently received packet and the index of the rate limit parameter, and adds the length value of the currently received packet to the length of the previous received packet. The mantissa of the value is obtained, and the new packet length value is obtained. Then, according to the obtained new packet length value, the new packet tail number and the actual packet length value currently required to be rate-limited are obtained according to the preset calculation rule; The actual packet length value of the current rate limit and the previously obtained rate limit parameter index are obtained, and the rate limit result is obtained. Finally, when the obtained rate limit result meets the preset rate limit condition, the current received packet is forwarded, and The new packet tail number is used as the mantissa of the length value of the current received packet. When the rate limit result does not meet the preset rate limit condition, the current received packet is discarded, and the length of the previous received packet is The mantissa is used as the mantissa of the length value of the currently received message. The invention improves the speed limit accuracy. FIG. 3 is a schematic flowchart diagram of another embodiment of a token bucket-based traffic policing method according to the present invention. Referring to FIG. 3, the traffic policing method based on the token bucket in this embodiment is based on FIG. 2, and before step S02, the method further includes: Step S011: Acquire a mantissa of a length value of a previous received packet; specifically, the implementation For example, the mantissa Prior Tail Val of the length value of the previous received message is read from the specific storage space A. In this embodiment, the value of the mantissa of the length value of the previous received message is 0. Further, before the step S03, the embodiment further includes: Step S021: Obtain a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value; specifically, the embodiment is The token bucket depth parameter is read from a specific storage space B, where the token bucket depth parameter includes a mantissa mask value Tail Mask and a message length shift value Shift Right. In this embodiment, since the configuration value of the mantissa mask value Tail Mask is 0xf, the configuration value of the message length shift value Shift Right is 4, and therefore, the mantissa mask value Tail Mask obtained in step S021 of this embodiment is 0xf, the obtained message length shift value Shift Right is 4. The token bucket-based traffic policing method in this embodiment first obtains the current received packet length value, the rate limit parameter index, the mantissa of the length of the previous received packet, and the token bucket depth parameter (including the mantissa mask). The code value and the message length shift value), the length value of the received current received message is added to the mantissa of the length value of the previous received message to obtain a new message length value; and then the new report is obtained. The text length value and the mantissa mask value are ANDed to obtain a new message mantissa, and according to the message length shift value, the obtained new message length value is right-shifted to obtain the current actual speed limit report. The length of the text; then, according to the actual speed limit of the current required speed limit The speed value and the previously obtained speed limit parameter index are obtained, and the speed limit result is obtained. Finally, when the obtained speed limit result satisfies the preset speed limit condition, the current received message is forwarded, and the new message tail is used as the current If the rate limit result does not meet the preset rate limit condition, the current received packet is discarded, and the mantissa of the length of the previous received packet is used as the length of the current received packet. The mantissa of the value. The invention improves the speed limit accuracy. The present invention also provides a token bucket-based traffic policing device. FIG. 4 is a schematic diagram of a module structure of an embodiment of the token bucket-based traffic policing device of the present invention. Referring to FIG. 4, the token bucket-based traffic policing 200 in this embodiment includes a receiving module 201, an acquiring module 202, a calculating module 203, a rate limiting module 204, a decision module 205, and a sending module 206, where: the receiving module 201, Specifically, in the embodiment of the present invention, the Ethernet packet received by the receiving module 201 is referred to as the currently received packet, and the current received packet received by the receiving module 201 in the initial state. Refers to the first Ethernet packet. The storage module 2021 is configured to store a mantissa of a length value of the previous received message and a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value Tail Mask and a message length shift value Shift Right. The collecting module 202 is configured to obtain the length value of the currently received packet and the index of the rate limit parameter. Specifically, in this embodiment, after the receiving module 201 receives the currently received packet, the collecting module 202 obtains the length of the currently received packet. The value Current Length and the speed limit parameter index Policy Index. The speed limit parameter indexing includes a committed information rate CIR, an excess information rate EIR, a committed burst length CBS, an excess burst length EBS, a color sensitive mode, and a rate limiting algorithm. In this embodiment, the configuration value of the current length of the received packet is 100 bytes, and the configuration value of the speed limit parameter indexing index is 0, that is, the current receiving report obtained by the collecting module 202 in this embodiment is obtained. The length value of the text is 100 and the index of the speed limit parameter is 0. In this embodiment, the collection module 202 is further configured to obtain the prologue of the length of the previous received packet, the Prior TailVal, and the depth parameter of the token bucket, and the token bucket depth parameter includes the tail mask value Tail Mask and the packet. The length shift value Shift Right. Specifically, the acquisition module 202 reads the mantissa Prior TailVal of the length value of the previous received message from the specific storage space A of the storage module 2021, and reads the token bucket depth parameter from the specific storage space B of the storage module 2021. The mantissa mask value Tail Mask and the message length shift value Shift Right), in this embodiment, the previous one The mantissa of the length value of the received message has a value of 0, the Tail Mask of the mantissa is Oxf (hexadecimal), and the length of the message length Shift Right is 4. In this embodiment, the storage module 2021 is disposed in the collection module 202. The calculation module 203 is configured to add the obtained length value of the currently received packet to the mantissa of the length value of the previous received packet to obtain a new packet length value; and according to the new packet length value, according to the new packet length value The preset calculation rule is used to obtain the new packet tail number and the actual packet length value that needs to be limited. Specifically, after the acquisition module 202 obtains the length value Current of the currently received message, the calculation module 203 is configured to add the length value (Current Length (100) of the received current received message to the previous received message. A new packet length value Update Length, which is the new packet length value obtained in this embodiment, is Update Length = 100 + 0 = 100. Moreover, in this embodiment, the calculation module 203 is further configured to perform a new operation on the new packet length value Update Length (100+0) and the mantissa mask value Tail Mask (Oxf) acquired by the acquisition module 202 to obtain a new The message mantissa Update TailVal; at the same time, the calculation module 203 performs a right shift operation on the new message length value Update Length according to the message length shift value Shift Right acquired by the acquisition module 202, to obtain the actual current speed limit required. Packet length value. In this embodiment, since the new packet length value Update Length is 100 and the mantissa mask value Tail Mask is Oxf, in this embodiment, the new packet mantissa Update TailVal is equal to the new packet length value Update Length ( 100) and the result of the operation of the mantissa mask value Tail Mask (Oxf), the new message mantissa Update TailVal is equal to 4. The actual packet length value of the current rate limit is equal to the new packet length value. The update length of the message length is 0. (100) Move 4 bits to the right to get the actual packet length value of the current rate limit. The Policy Length is equal to 6. The speed limit module 204 is configured to obtain a speed limit result according to the actual message length value and the speed limit parameter index of the current required speed limit. Specifically, in this embodiment, after the calculation module 203 is configured to calculate the new packet tail number Update TailVal (4) and the actual packet length value of the current rate limit (Policing Length (6)), the rate limiting module 204 is configured according to the collecting module 202. The rate limit parameter of the speed limit parameter indexing (0) of the obtained speed limit parameter is selected to limit the speed of the actual packet length value (Policing Length (6)), and the speed limit result is obtained. The decision module 205 is configured to use the new message mantissa or the mantissa of the length value of the previous received message as the mantissa of the length value of the currently received message according to the speed limit result and the preset speed limit condition. Specifically, when the speed limit result obtained by the speed limit module 204 meets the preset speed limit condition, the decision module 205 uses the new message tail number Update Tail Val (4) as the mantissa of the length value of the currently received message; When the speed limit result obtained by the module 204 does not satisfy the preset speed limit condition, the decision module 205 takes the mantissa Prior TailVal (0) of the length value of the previous received message as the mantissa of the length value of the currently received message. The sending module 206 is configured to forward or discard the currently received packet according to the speed limit result and the preset speed limit condition. Specifically, in this embodiment, when the rate limit result obtained by the rate limiting module 204 meets the preset rate limit condition, the sending module 206 forwards the currently received message; the speed limit result obtained by the rate limiting module 204 is not satisfied. When the rate limit condition is preset, the sending module 206 discards the currently received message. In the token bucket-based traffic policing device, the receiving module receives the Ethernet packet; the storage module stores the mantissa of the length of the received packet and the token bucket depth parameter (including the mantissa mask value and the report). The length of the text is shifted by the acquisition module. The acquisition module obtains the length value of the current received packet and the index of the speed limit parameter. The calculation module sets the length of the currently received packet to the mantissa of the length of the received packet. The new packet length value is obtained, and the calculation module is further configured to obtain a new packet tail number and an actual packet length value that needs to be rate-limiting according to the new packet length value according to the new packet length value; The actual packet length value and the rate limit parameter index of the current rate limit are obtained, and the speed limit result is obtained. The decision module uses the new packet tail number or the mantissa of the length value of the previous received packet as the current received packet according to the speed limit result. The mantissa of the length value; the sending module forwards or discards the currently received packet according to the rate limit result. The present invention improves the speed limit accuracy relative to the prior art. The above description is only the preferred embodiment of the present invention, and is not intended to limit the scope of the invention, and the equivalent structure or equivalent flow transformation made by the specification and the drawings of the present invention may be directly or indirectly applied to other related The technical field is equally included in the scope of patent protection of the present invention. Industrial Applicability The embodiment of the present invention provides the foregoing technical solution, which may be applied to the process of the traffic policing based on the token bucket, obtaining the length value of the currently received packet and the index of the rate limit parameter, and acquiring the currently received packet. The length value is added to the mantissa of the length value of the previous received packet to obtain a new packet length value. Then, according to the obtained new packet length value, the new packet tail number and the current limit are obtained according to the preset calculation rule. The actual value of the actual packet length is obtained. Then, the speed limit result is obtained according to the actual packet length value of the current rate limit and the previously obtained speed limit parameter index. Finally, according to the speed limit result and the preset speed limit condition, Receive packets for speed limiting, and new The mantissa of the message or the mantissa of the length value of the last received message is used as the mantissa of the length value of the currently received message, which effectively increases the speed limit accuracy.

Claims

权 利 要 求 书 、 一种基于令牌桶的流量监管方法, 包括: 获取当前接收报文的长度值和限速参数索引; A request for a traffic policing method based on a token bucket includes: obtaining an index of a length value and a speed limit parameter of a currently received packet;
将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新的报文长度值; 根据所述新的报文长度值, 按照预置计算规则, 获得新的报文尾数以及当 前需要限速的实际报文长度值;  Adding the length value of the currently received packet to the mantissa of the length value of the previous received packet, and obtaining a new packet length value; according to the new packet length value, obtaining a new according to the preset calculation rule The number of the message tails and the actual message length value that needs to be speed limited at present;
根据所述当前需要限速的实际报文长度值及所述限速参数索引, 获得限速 结果;  Obtaining a speed limit result according to the actual packet length value currently required to limit the speed and the index of the speed limit parameter;
根据所述限速结果及预置限速条件, 对所述当前接收报文进行限速处理, 并将所述新的报文尾数或所述上一次接收报文的长度值的尾数作为当前接收报 文的长度值的尾数。 、 根据权利要求 1所述的基于令牌桶的流量监管方法, 其中, 所述根据所述限速 结果及预置限速条件, 对所述当前接收报文进行限速处理, 并将所述新的报文 尾数或所述上一次接收报文的长度值的尾数作为当前接收报文的长度值的尾数 包括: 当所述限速结果满足预置限速条件时,将所述当前接收报文进行转发处理, 并将所述新的报文尾数作为当前接收报文的长度值的尾数;  Performing rate limiting processing on the currently received packet according to the rate limiting result and the preset rate limiting condition, and using the new packet tail number or the mantissa of the length value of the last received packet as the current receiving The mantissa of the length value of the message. The token bucket-based traffic policing method according to claim 1, wherein the speed limit processing is performed on the currently received packet according to the speed limit result and the preset speed limit condition, and the The new message tail number or the mantissa of the length value of the last received message as the mantissa of the length value of the current received message includes: when the speed limit result satisfies the preset speed limit condition, the current receiving report Performing forwarding processing, and using the new message mantissa as the mantissa of the length value of the currently received message;
当所述限速结果不满足预置限速条件时, 将所述当前接收报文进行丢弃处 理, 并将所述前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾 数。 、 根据权利要求 2所述的基于令牌桶的流量监管方法, 其中, 所述将获取到的当 前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新的报文长度 值之前还包括: 获取前一个接收报文的长度值的尾数。 根据权利要求 3所述的基于令牌桶的流量监管方法, 其中, 所述根据所述新的 报文长度值, 按照预置计算规则, 获得新的报文尾数以及当前需要限速的实际 报文长度值之前还包括: 获取令牌桶桶深参数, 所述令牌桶桶深参数包括尾数掩码值和报文长度移 位值。 根据权利要求 4所述的基于令牌桶的流量监管方法, 其中, 所述根据所述新的 报文长度值, 按照预置计算规则, 获得新的报文尾数以及当前需要限速的实际 报文长度值包括: 将所述新的报文长度值和所述尾数掩码值做与运算, 获得新的报文尾数; 按照所述报文长度移位值, 对所述新的报文长度值做右移运算, 获得当前需要 限速的实际报文长度值。 一种基于令牌桶的流量监管装置, 包括接收模块、 采集模块、 计算模块、 限速 模块、 决策模块及发送模块; When the rate limit result does not meet the preset rate limit condition, the current received message is discarded, and the mantissa of the length value of the previous received message is used as the mantissa of the length value of the currently received message. . The token bucket-based traffic policing method according to claim 2, wherein the length value of the currently received packet is added to the mantissa of the length value of the previous received packet to obtain a new packet. The length value also includes: The mantissa of the length value of the previous received message. The token bucket-based traffic policing method according to claim 3, wherein the obtaining, according to the new packet length value, a new packet tail number and an actual current rate limit request according to a preset calculation rule The text length value also includes: Obtaining a token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value. The token bucket-based traffic policing method according to claim 4, wherein the obtaining, according to the new packet length value, a new packet tail number and an actual current rate limit request according to a preset calculation rule The length value of the text includes: performing an AND operation on the new packet length value and the mantissa mask value to obtain a new packet mantissa; and according to the packet length shift value, the new packet length The value is shifted to the right to obtain the actual packet length value that needs to be limited. A token bucket-based traffic policing device includes a receiving module, an acquiring module, a calculating module, a speed limiting module, a decision module, and a sending module;
所述接收模块, 设置为接收以太网报文;  The receiving module is configured to receive an Ethernet packet;
所述采集模块, 设置为获取当前接收报文的长度值和限速参数索引; 所述计算模块, 设置为将获取到的当前接收报文的长度值加上前一个接收 报文的长度值的尾数, 得到新的报文长度值; 以及根据所述新的报文长度值, 按照预置计算规则, 获得新的报文尾数以及当前需要限速的实际报文长度值; 限速模块, 设置为根据所述当前需要限速的实际报文长度值及所述限速参 数索引, 获得限速结果;  The acquiring module is configured to obtain a length value of the currently received packet and a speed limit parameter index; the calculating module is configured to add the length value of the currently received packet to the length of the previous received packet. The mantissa, the new packet length value is obtained; and according to the new packet length value, according to the preset calculation rule, the new packet tail number and the actual packet length value currently required to be rate-limiting are obtained; Obtaining a speed limit result according to the actual packet length value and the speed limit parameter index of the current required speed limit;
所述决策模块, 设置为根据所述限速结果及预置限速条件, 将所述新的报 文尾数或所述前一个接收报文的长度值的尾数作为当前接收报文的长度值的尾 数;  The decision module is configured to use, as the speed limit result and the preset speed limit condition, the new message tail number or the mantissa of the length value of the previous received message as the length value of the current received message. Mantissa
所述发送模块, 设置为根据所述限速结果及预置限速条件, 对所述当前接 收报文进行转发或丢弃处理。 根据权利要求 6所述的基于令牌桶的流量监管装置, 其中, 所述决策模块设置 为:  The sending module is configured to forward or discard the current received packet according to the speed limit result and the preset speed limit condition. The token bucket-based traffic policing device according to claim 6, wherein the decision module is configured to:
当所述限速结果满足预置限速条件时, 将所述新的报文尾数作为当前接收 报文的长度值的尾数; 当所述限速结果不满足预置限速条件时, 将所述前一个接收报文的长度值 的尾数作为当前接收报文的长度值的尾数。 、 根据权利要求 7所述的基于令牌桶的流量监管装置, 其中, 所述发送模块设置 为: When the speed limit result satisfies the preset speed limit condition, the new message tail number is used as the mantissa of the length value of the current received message; when the speed limit result does not satisfy the preset speed limit condition, The mantissa of the length value of the previous received message is used as the mantissa of the length value of the currently received message. The token bucket-based traffic policing device according to claim 7, wherein the sending module is configured to:
当所述限速结果满足预置限速条件时,将所述当前接收报文进行转发处理; 当所述限速结果不满足预置限速条件时, 将所述当前接收报文进行丢弃处 理。 、 根据权利要求 8所述的基于令牌桶的流量监管装置, 其中, 所述采集模块还设 置为:  When the speed limit result meets the preset speed limit condition, the current received message is forwarded; when the speed limit result does not meet the preset speed limit condition, the current received message is discarded. . The token bucket-based traffic policing device according to claim 8, wherein the collection module is further configured to:
获取前一个接收报文的长度值的尾数; 以及获取令牌桶桶深参数, 所述令 牌桶桶深参数包括尾数掩码值和报文长度移位值。 0、 根据权利要求 9所述的基于令牌桶的流量监管装置, 其中, 所述计算模块设置 为:  Obtaining the mantissa of the length value of the previous received message; and obtaining the token bucket depth parameter, where the token bucket depth parameter includes a mantissa mask value and a message length shift value. The token bucket-based traffic policing device according to claim 9, wherein the calculating module is configured to:
将获取到的当前接收报文的长度值加上前一个接收报文的长度值的尾数, 得到新的报文长度值;以及将所述新的报文长度值和所述尾数掩码值做与运算, 获得新的报文尾数; 并按照所述报文长度移位值, 对所述新的报文长度值做右 移运算, 获得当前需要限速的实际报文长度值。  Adding the obtained length value of the currently received packet to the mantissa of the length value of the previous received packet to obtain a new packet length value; and performing the new packet length value and the mantissa mask value And the operation, obtaining a new message mantissa; and performing a right shift operation on the new message length value according to the packet length shift value, to obtain an actual message length value that needs to be rate-limited.
PCT/CN2014/079984 2014-04-21 2014-06-16 Method and device for traffic policing based on token bucket WO2015161552A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410160940.7 2014-04-21
CN201410160940.7A CN105024932A (en) 2014-04-21 2014-04-21 Traffic policing method and apparatus based on token bucket

Publications (1)

Publication Number Publication Date
WO2015161552A1 true WO2015161552A1 (en) 2015-10-29

Family

ID=54331666

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/079984 WO2015161552A1 (en) 2014-04-21 2014-06-16 Method and device for traffic policing based on token bucket

Country Status (2)

Country Link
CN (1) CN105024932A (en)
WO (1) WO2015161552A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108833292A (en) * 2018-05-04 2018-11-16 新华三技术有限公司 Flow control methods and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101083563A (en) * 2007-07-20 2007-12-05 杭州华三通信技术有限公司 Method and apparatus for preventing distributed refuse service attack
CN101997766A (en) * 2009-08-31 2011-03-30 中兴通讯股份有限公司 Method and system for limiting speed of token bucket based on priority
US20110283155A1 (en) * 2010-05-11 2011-11-17 Electronics And Telecommunications Research Institute Apparatus and method for transmitting/receiving data in a communication system
CN102882809A (en) * 2012-10-26 2013-01-16 杭州迪普科技有限公司 Network speed-limiting method and device based on message buffering

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102014075B (en) * 2010-12-21 2013-07-24 杭州华三通信技术有限公司 Traffic policing method and device
CN102413042A (en) * 2011-11-14 2012-04-11 盛科网络(苏州)有限公司 Timestamp-updating-token-bucket-based traffic policing method and system
CN103312621B (en) * 2013-06-07 2016-08-10 深圳中兴网信科技有限公司 Flow control system and flow control methods

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101083563A (en) * 2007-07-20 2007-12-05 杭州华三通信技术有限公司 Method and apparatus for preventing distributed refuse service attack
CN101997766A (en) * 2009-08-31 2011-03-30 中兴通讯股份有限公司 Method and system for limiting speed of token bucket based on priority
US20110283155A1 (en) * 2010-05-11 2011-11-17 Electronics And Telecommunications Research Institute Apparatus and method for transmitting/receiving data in a communication system
CN102882809A (en) * 2012-10-26 2013-01-16 杭州迪普科技有限公司 Network speed-limiting method and device based on message buffering

Also Published As

Publication number Publication date
CN105024932A (en) 2015-11-04

Similar Documents

Publication Publication Date Title
EP3618372B1 (en) Congestion control method and network device
CN111316605B (en) Layer 3 fair rate congestion control notification
WO2020042624A1 (en) Transmission rate control method and apparatus, sending device and receiving device
US8416684B2 (en) Time and data rate policing
US11411882B2 (en) Generating automatic bandwidth adjustment policies per label-switched path
US9674102B2 (en) Methods and network device for oversubscription handling
CN106878116B (en) flow rate limiting method and device
CN111800351A (en) Congestion notification packet generation by a switch
US7467223B2 (en) TCP-friendly markers and methods using token buckets
US9282038B2 (en) Policy control enforcement at a packet gateway
EP3122012B1 (en) Data processing method and apparatus for openflow network
US20150236955A1 (en) Congestion Notification in a Network
EP2709320B1 (en) Method and apparatus for sending packet
WO2016202224A1 (en) Method and device for adjusting transport layer parameter
Jiang et al. Cltcp: an adaptive tcp congestion control algorithm based on congestion level
WO2015161552A1 (en) Method and device for traffic policing based on token bucket
WO2018010618A1 (en) Method and device for acquiring path information about data packet
JP4500701B2 (en) Packet transfer device
CN112532535B (en) Method and device for optimizing network congestion
WO2013000112A1 (en) Rate limit method and device for leaky bucket
WO2022100392A1 (en) Service transmission method, system, and computer-readable storage medium
JP2016158080A (en) Bandwidth controller, bandwidth control method and program
Liu et al. Implementation of PFC and RCM for RoCEv2 Simulation in OMNeT++
Shinohara et al. Queue management scheme stabilizing buffer utilization in the IP router
JP2004357177A (en) Router, congestion control method for router, program and recording medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14890026

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14890026

Country of ref document: EP

Kind code of ref document: A1